CF
Tuilot
退役ACMer
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Educational Codeforces Round 80 c题 Two Arrays 隔板法
You are given two integers n and m. Calculate the number of pairs of arrays (a,b) such that: the length of both arrays is equal to m; each element of each array is an integer between 1 and n (inclusiv...原创 2020-02-03 14:03:48 · 199 阅读 · 0 评论 -
CF 1446 C Xor Tree (分治)
可以对所有数建一个01字典树,然后可以发现每个点找最小的异或值就是在字典树中离它最近的点(可以把整个二叉树都画出来会更好看一点),对于每一个非叶子结点它的两个子树中的点如果想成为连通图的话,只能是两个子节点中数量都不能超过两个,不然就是两个连通图了,所以保留两个中的最大值另一个删得只剩一个值就好。对所有的非叶子结点都做这样的操作后就是最优结果了,将空节点减掉时间复杂度就能接受了。可以发现每个节点的子树会表示一个数的范围,所以不用建字典树就可以。 #include<bits/stdc++.h>..原创 2021-01-21 11:10:58 · 279 阅读 · 0 评论 -
CF 1470B Strange Definition (hash)
首先定义一种关系就叫相关吧(相邻与传统观念太冲突了),如果lcm(x,y)gcd(x,y)\frac{lcm(x,y)}{gcd(x,y)}gcd(x,y)lcm(x,y)是完全平方数那么x和y就是相关的。 暂且定义 [x] 表示 x 是完全平方数 化简一下可以得到x∗ygcd2\frac{x*y}{gcd^2}gcd2x∗y 所以如果 [xy] 那么x和y就相关。 相关性具有传递性:如果[xyxyxy]且[yzyzyz]相关,那么[xy2zxy^2zxy2z],所以[xzxzxz]。 所以d数组..原创 2021-01-17 13:06:46 · 319 阅读 · 0 评论 -
Codeforces Round #693 (Div. 3)
传送门 E : 首先维护hi>=wi(小于也没问题),然后h作为第一关键字递增排序。 然后遍历这个数组,维护一个最小的w的位置,还要保证该位置的h严格小于当前点的h,双指针扫一遍即可。 #include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=1000100; typedef pair<int,int> pii; #define fi first #define se secon原创 2021-01-17 12:40:56 · 160 阅读 · 0 评论 -
CF 1473E Minimum Path
如果没有最大值和最小值就是最短路模板了,如果在跑图过程中同时维护最大值最小值就太麻烦了,可以对每一条边都当做最大值最小值去试一试,状态表示为dist[i][0/1][0/1],第二维表示是否减过边权,第三维表示是否加过边权。这样就可以跑迪杰斯特拉了。也可理解为分层图最短路。 #include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=1000010; int t; int n,m; ll di..原创 2021-01-17 12:17:48 · 303 阅读 · 0 评论 -
CF 1288D Minimax Problem(二分+状压)
最大化最小值很容易想到二分,但是怎么check是个问题,check(ans)是否成立时需要找到两个行使得每一位的最大值都大于等于ans,也就是说每一位至少存在一个数大于等于ans,可以观察到m<=8,所以可以状压,将每一行大于等于ans的位置1,小于的位置0.最后判断是否存在两行状态或之后二进制位都为1即可。 #include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=300010; i.原创 2021-01-15 14:05:58 · 338 阅读 · 1 评论 -
CF 1453D Checkpoints (期望+构造)
构造一个这样的游戏关卡使得玩家通过全部关卡的期望步数等于k。 首先肯定是分块的,每个1以及后面的连续0是同一块。先计算一下每一种块的的期望: 1 : E = 12\frac{1}{2}21 * 1 + 12\frac{1}{2}21 * (1+E) (没通过返回1之后又是独立重复实验期望不变) 解得 e[1] = 2 ; 10 : E = 14\frac{1}{4}41 * 2 + 12\frac{1}{2}21 * (1+E) + 14\frac{1}{4}41 * (..原创 2021-01-13 15:13:18 · 287 阅读 · 0 评论 -
Codeforces Round #645 (Div. 2)
A #include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=200010; int t,n,m; int main() { cin>>t; while(t--) { cin>>n>>m; int ans=n/2*m; ans+=(n&1)*(m+1)/2; cout<<ans<<endl; } re原创 2020-05-27 11:08:18 · 205 阅读 · 0 评论 -
Codeforces Round #644 (Div. 3)
A #include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=200010; int t,a,b; int main() { cin>>t; while(t--) { cin>>a>>b; if(a<b) swap(a,b); int res=max(a,b*2); cout<<res*res<<endl;原创 2020-05-25 09:28:41 · 162 阅读 · 0 评论 -
Codeforces Round #641 (Div. 2)
A n是奇数,f(n)一定是奇数;n是偶数,f(n)一定是2; #include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=200010; int t; ll n,k; bool pr[N]; int main() { cin>>t; while(t--) { cin>>n>>k; if((n&1)&&k) { bo原创 2020-05-13 15:49:18 · 214 阅读 · 0 评论 -
AtCoder Beginner Contest 167
A 这点判断字符串就可以了,字符串是可以比较大小的。 #include<bits/stdc++.h> using namespace std; typedef long long ll; int main() { string a,b; cin>>a>>b; if(a==b.substr(0,b.size()-1)) puts("Yes"); else puts("No"); return 0; } B 直接计算就好了。 #include<bits/原创 2020-05-11 13:12:17 · 241 阅读 · 0 评论 -
Codeforces Round #640 (Div. 4)
A #include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=200010; int t,n,m; int main() { cin>>t; while(t--) { cin>>n; vector<int> ve; int cnt=0; while(n) { if(n%10) ve.push_back((n%10)*pow(10,原创 2020-05-10 17:37:12 · 146 阅读 · 0 评论 -
Codeforces Round #639 (Div. 2)
这场比赛打的真糟心,幸亏不计分了,美滋滋的溜了。。。 A 只有一行或者只有一列是一定可以的,其他情况只有两行两列可以(首尾相连排一圈)。 #include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=200010; int t,n,m; int main() { cin>>t;...原创 2020-05-07 22:08:01 · 148 阅读 · 0 评论 -
Codeforces Round #638 (Div. 2)
A 选择前n/2 - 1个最小的和一个最大的。 ps:2^31爆有符号int,位运算的优先级很小。 #include<bits/stdc++.h> using namespace std; typedef long long ll; #define pii pair<int,int>; const int N=200010; int t,n,m; ll ans; int m...原创 2020-05-03 08:54:10 · 151 阅读 · 0 评论 -
Educational Codeforces Round 86 (Rated for Div. 2)
A 当b>2*a时每次只减一个数会花费更少,否则先同减到其中一个数为0再计算会更少。 #include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=200010; int t,n,m; ll x,y,a,b; int main() { cin>>t; while(t--...原创 2020-04-27 11:00:15 · 171 阅读 · 0 评论 -
Codeforces Round #636 (Div. 3)(A-E)
A k>1,所以系数和s最小等3,k+1,s就*2再+1,直到n取余s等0就可以输出了 (已知解一定存在) #include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=200010; int t,n; int main() { cin>>t; while(t--) ...原创 2020-04-22 15:58:14 · 221 阅读 · 0 评论 -
Codeforces Round #634 (Div. 3)
A n是奇数输出一半,是偶数输出一半减1 #include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=200010; int t,n; int main() { cin>>t; while(t--) { cin>>n; cout<<(n-1...原创 2020-04-14 10:29:50 · 122 阅读 · 0 评论 -
Educational Codeforces Round 85 (Rated for Div. 2)
A 直接判断就可以了 #include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=100010; #define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(); int t,n,a[N],b[N]; int main() { cin&...原创 2020-04-11 08:57:17 · 121 阅读 · 0 评论 -
Codeforces Round #632 (Div. 2)
A 点(1,1)填W,其他点全部填B就可以了 #include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=100010; int t,n,m; int main() { cin>>t; while(t--) { cin>>n>>m; for...原创 2020-04-09 20:18:56 · 123 阅读 · 0 评论 -
Codeforces Round #631 (Div. 2)(A-C)
A 统计之后补x个空就可以了,最大应该是max(ai)+x<=200; #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> PII; #define IOS ios::sync_with_stdio(0); const int N=1000...原创 2020-04-04 18:03:09 · 112 阅读 · 0 评论 -
Codeforces Round #630 (Div. 2)(A-D)
A 在一个方格可以多次,那么可以在相邻的两个方格来回走,然后会在左右或者的一个方向剩下几步,判断是否越边界就可以了,除此之外还要特判x1== x2或者y1== y2(刚才那样有一个前提条件,那个方向上得能迈出去,感谢样例) #include<bits/stdc++.h> using namespace std; const int N=100010; typedef long long...原创 2020-04-01 09:12:33 · 216 阅读 · 0 评论 -
Codeforces Round #629 (Div. 3)(A-D)
A 取模运算就行。 #include<bits/stdc++.h> using namespace std; const int N=100010; typedef long long ll; #define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); int main() { ll t,n,m; cin>>t...原创 2020-03-28 16:38:08 · 135 阅读 · 0 评论 -
Educational Codeforces Round 84
链接:http://codeforces.com/contest/1327 A 问k个不相同的正奇数相加是否等于n,k个奇数相加的奇偶性一定与k相同,而且k个不相同的正奇数最小等于k^2 (1+3+…+2*k-1)判断一下就可以了 #include<bits/stdc++.h> using namespace std; typedef long long ll; #define IOS...原创 2020-03-24 16:21:52 · 190 阅读 · 0 评论
分享