D - The Child and Sequence 思路: 因为有区间取模操作所以没法用标记下传: 我们发现,当一个数小于要取模的值时就可以放弃: 凭借这个来减少更新线段树的次数: 来,上代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define maxn 100005 #define ll lo…
C - Sagheer and Nubian Market 思路: 二分: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 1000005 #define ll long long ll n,s,ai[maxn],ci[maxn]; inline void in(ll &now) { ; ') Cget=getchar(); +Cget-',Cget=getchar(); } int main() { ;i&…
399B - Red and Blue Balls 思路: 惊讶的发现,所有的蓝球的消除都是独立的: 对于在栈中深度为i的蓝球消除需要2^i次操作: 代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; ; int main() { // freopen("ball.in","r…
C - Andryusha and Colored Balloons 思路: 水题: 代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define maxn 200005 ],V[maxn<<],dis[maxn],ans; void dfs(int now,int fa) { ; for…
E - Little Elephant and Shifts 思路: 一次函数线段树(疯狂debug): b不断循环左移,判断每次最小的|i-j|,a[i]=b[j]: 仔细观察发现,每个bi移动时,|i-j|呈现多个一次函数图像: 所以用线段树来维护这些一次函数图像: 线段树维护一次函数,当两个函数在区间没有交点时: 判断哪个在图像较下的位置,然后覆盖: 当有交点时,保留最优,将另一条传下去: 时间复杂度O(nlog^2n); 代码: #include <cmath> #include &l…
221C 思路: 水题: 代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define maxn 200005 int n,ai[maxn],bi[maxn],ans; inline void in(int &now) { ;now=; char Cget=getchar(); ') { ;…
221D - Little Elephant and Array 思路: 莫队: 代码: #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define maxn 100005 struct QueryType { int l,r,id; }; struct Que…
221B - Little Elephant and Numbers 思路: 水题: 代码: #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; ; ]; int main() { scanf("%d",&n); int pos=n; ) i…
A - Little Elephant and Function 思路: 水题: 代码: #include <cstdio> #include <iostream> using namespace std; int n; int main() { scanf("%d",&n); printf("%d ",n); ;i<n;i++) printf("%d ",i); ; }…
D. The Child and Sequence Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/438/problem/D Description At the children's day, the child came to Picks's house, and messed his house up. Picks was angry at him. A lot of important…