题目:Problem K. PiecemakingInput file: standard inputOutput file: standard outputTime limit: 1 secondMemory limit: 512 mebibytesThe civil war in Berland continues for five years already. The United Nation decided to end the bloodshed.Berland consists o…
题目: Problem D. Great AgainInput file: standard inputOutput file: standard outputTime limit: 2 secondsMemory limit: 512 megabytesThe election in Berland is coming. The party United Berland is going to use its influence to win themagain. The crucial co…
1000w的数组,一开始都是2^31-1,然后经过5*10^7次随机位置的随机修改,问你每次的全局最小值. 有效的随机修改的期望次数很少,只有当修改到的位置恰好是当前最小值的位置时才需要扫一下更新最小值. 分个块或者直接暴力都可以. #include<cstdio> #include<iostream> #include<cmath> #include<algorithm> using namespace std; int sz,l[10005],r[100…
A. Pieces of Parentheses 将括号串排序,先处理会使左括号数增加的串,这里面先处理减少的值少的串:再处理会使左括号数减少的串,这里面先处理差值较大的串.确定顺序之后就可以DP了. 时间复杂度$O(n^3)$. #include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int N=310,inf=1000000; int n,i,j,m,all,…
A. Base $i - 1$ Notation 两个性质: $2=1100$ $122=0$ 利用这两条性质实现高精度加法即可. 时间复杂度$O(n)$. #include<stdio.h> #include<iostream> #include<string.h> #include<string> #include<ctype.h> #include<math.h> #include<set> #include<…
1. GUI 按题意判断即可. #include<stdio.h> #include<iostream> #include<string.h> #include<string> #include<ctype.h> #include<math.h> #include<set> #include<map> #include<vector> #include<queue> #include&l…
A. City Wall 找规律. #include<stdio.h> #include<iostream> #include<string.h> #include<string> #include<ctype.h> #include<math.h> #include<set> #include<map> #include<vector> #include<queue> #include…
A. Ability Draft 记忆化搜索. #include<stdio.h> #include<iostream> #include<string.h> #include<string> #include<ctype.h> #include<math.h> #include<set> #include<map> #include<vector> #include<queue> #i…
A. Donut 扫描线+线段树. #include<cstdio> #include<algorithm> using namespace std; typedef long long ll; const int N=800010,M=2222222; int n,m,cnt,i,j;ll L,R,D,a[N]; int tag[M],v[M],ans; struct E{ ll x,l,r;int s; E(){} E(ll _x,ll _l,ll _r,int _s){x=_…
A. Three Arrays 枚举每个$a_i$,双指针出$b$和$c$的范围,对于$b$中每个预先双指针出$c$的范围,那么对于每个$b$,在对应$c$的区间加$1$,在$a$处区间求和即可. 树状数组维护,时间复杂度$O(n\log n)$. #include<stdio.h> #include<iostream> #include<string.h> #include<string> #include<ctype.h> #include&…