分析:首先了解mex,mex是一个区间的最小未出现的自然数(包括0),如果一个数组的长度为n,那么mex最多为n。对于本题,我们要求mex的最大值,当我们选取的数是x的时候,我们为了使mex大于或等于x+1或者更多,那么就选x,选重复的元素没有影响,我们从i=0,1...,k-1,如果数组中包含i 那么就选出来,因为mex有机会...
intr, c; intans = h * w; set<int>::iterator ia, ic; set<int, greater<>>::iterator ib, id; while(q--) { scanf("%d%d", &r, &c); if(T[r].find(c) != T[r].end()) { del(r, c); ans--; }else{ ia = T[r].upper_bound(c); ...
abc294 d,set模拟。 e,两行可以哪行短了放哪行,然后就可以保证多出来部分的只有一种颜色,累加多出来的部分和新加的长度取min f,二分浓度,通过判断浓度大于等于mid来缩小区间,这里进行等价移项,0/1分数规划。 g,一棵树上的两点距离distu +distv -distlca...
set<int> a; for(inti =0; i < n; ++i) { ints, c; cin >> s >> c; cnt[s] = c; a.insert(s); } intans =0; for(auto& i : a) { intsum =0; for(LL j = i;true; j = j + j) { sum = (sum + cnt[j]); if(sum <2) { cnt[j] = sum; break; } cnt[j]...
C - abc285_brutmhyhiizp https://atcoder.jp/contests/abc285/tasks/abc285_c 单独分享,遇到了个坑,耽误了很多时间 D - Change Usernames https://atcoder.jp/contests/abc285/tasks/abc285_d 板子题,解题思路就不赘述了 小码匠代码 代码语言:javascript ...
C - Coprime Set 给定一个正整数N, 输出集合A={A1,A2,A3...An},对于这个集合来说,满足以下条件 1<=Ai<=10000;3<=N<=2500 Ai\neAj,且gcd(Ai,Aj) >1,且i\nej; gcd(A1,A2 ...An)=1; 输入N 输出集合A={A1,A2,A3...An} 解: 思路: 一...
For C, we can only move to integer points, so this will not work for any values that aren't perfect squares. → Reply Yianlaen 5 years ago, # | ← Rev. 2 +5 As a junior high student, I think Problem D is unfair because we haven't learnt the arcsin function before the con...
#include<cstdio> #include<algorithm> #include<cstdlib> #include<cstring> #include<string> #include<cmath> #include #include<set> #include<vector> #include<queue> #include<bitset> #include<ctime> #include<deque> #include<stack> #include...
If both of them 1, you need to check which one comes next first, for example if the order is AB then BC ( A = 1, B = 1, C = 0 ) you have to add +1 to B otherwise you add it to the other. If you're not in any of the other cases you can just add +1 to the mini...
C题 AC代码 #include <bits/stdc++.h> using namespace std; int n, m, k, a[110][110], b[110]; char is_ok[110]; int ans; void check { for (int i = 1; i <= m; i++) { int total = 0; for (int j = 1; j <= a[i][0]; j++) { total += b[a[i][j]]; }...