Codeforces Edu Round 68 (Rated for Div. 2)
比较水的一场。
题目链接:https://codeforces.com/contest/1194
A:
秒懂跟x没关系,答案就是2n。
B:
因为n*m<=4e5,统计每行每列点的数量后直接O(nm)暴力枚举维护最小值即可。
1 /* basic header */ 2 #include <bits/stdc++.h> 3 /* define */ 4 #define ll long long 5 #define dou double 6 #define pb emplace_back 7 #define mp make_pair 8 #define sot(a,b) sort(a+1,a+1+b) 9 #define rep1(i,a,b) for(int i=a;i<=b;++i) 10 #define rep0(i,a,b) for(int i=a;i<b;++i) 11 #define eps 1e-8 12 #define int_inf 0x3f3f3f3f 13 #define ll_inf 0x7f7f7f7f7f7f7f7f 14 #define lson curpos<<1 15 #define rson curpos<<1|1 16 /* namespace */ 17 using namespace std; 18 /* header end */ 19 20 int main() { 21 int t; cin >> t; 22 while (t--) { 23 int n, m, ans = int_inf; cin >> n >> m; 24 char s[n + 1][m + 1]; 25 int row[n + 1] = {0}, col[m + 1] = {0}; 26 rep1(i, 1, n) { 27 scanf("%s", s[i] + 1); 28 rep1(j, 1, m) { 29 if (s[i][j] == '.') row[i]++, col[j]++; 30 } 31 } 32 rep1(i, 1, n) { 33 rep1(j, 1, m) { 34 int k = row[i] + col[j]; 35 if (s[i][j] == '.') k--; 36 ans = min(ans, k); 37 } 38 } 39 printf("%d\n", ans); 40 } 41 return 0; 42 }
View Code
C:
O(n)扫一遍就行了。
1 /* basic header */ 2 #include <bits/stdc++.h> 3 /* define */ 4 #define ll long long 5 #define dou double 6 #define pb emplace_back 7 #define mp make_pair 8 #define sot(a,b) sort(a+1,a+1+b) 9 #define rep1(i,a,b) for(int i=a;i<=b;++i) 10 #define rep0(i,a,b) for(int i=a;i<b;++i) 11 #define eps 1e-8 12 #define int_inf 0x3f3f3f3f 13 #define ll_inf 0x7f7f7f7f7f7f7f7f 14 #define lson curpos<<1 15 #define rson curpos<<1|1 16 /* namespace */ 17 using namespace std; 18 /* header end */ 19 20 const int maxn = 110; 21 int q; 22 23 int main() { 24 scanf("%d", &q); 25 while (q--) { 26 string s, t, p; cin >> s >> t >> p; 27 int len1 = s.size(), len2 = t.size(), len3 = p.size(), ans = 1; 28 int a[26] = {0}; 29 for (auto c : p) a[c - 'a']++; 30 int i = 0, j = 0; 31 for (; i < len2; i++) { 32 if (j < len1 && t[i] == s[j]) j++; 33 else if (a[t[i] - 'a']) a[t[i] - 'a']--; 34 else { 35 ans = 0; 36 break; 37 } 38 } 39 if (j != len1) ans = 0; 40 if (ans) puts("YES"); else puts("NO"); 41 } 42 return 0; 43 }
View Code
D:
一看就是SG函数相关的题,打个表找规律发现循环节长度为3。简单推一下必胜必败点也可以猜出来。
1 /* basic header */ 2 #include <bits/stdc++.h> 3 /* define */ 4 #define ll long long 5 #define dou double 6 #define pb emplace_back 7 #define mp make_pair 8 #define sot(a,b) sort(a+1,a+1+b) 9 #define rep1(i,a,b) for(int i=a;i<=b;++i) 10 #define rep0(i,a,b) for(int i=a;i<b;++i) 11 #define eps 1e-8 12 #define int_inf 0x3f3f3f3f 13 #define ll_inf 0x7f7f7f7f7f7f7f7f 14 #define lson curpos<<1 15 #define rson curpos<<1|1 16 /* namespace */ 17 using namespace std; 18 /* header end */ 19 20 int t; 21 22 int main() { 23 scanf("%d", &t); 24 while (t--) { 25 int n, k; scanf("%d%d", &n, &k); 26 if (k % 3 == 0) { 27 int p = n % (k + 1) + 1; 28 if (p == k + 1) { 29 puts("Alice"); 30 continue; 31 } else { 32 if (p % 3 == 1) puts("Bob"); 33 else puts("Alice"); 34 } 35 } else { 36 if (n % 3 == 0) puts("Bob"); 37 else puts("Alice"); 38 } 39 } 40 return 0; 41 }
View Code
E:
树状数组+扫描线。
1 /* basic header */ 2 #include <bits/stdc++.h> 3 /* define */ 4 #define ll long long 5 #define dou double 6 #define pb emplace_back 7 #define mp make_pair 8 #define sot(a,b) sort(a+1,a+1+b) 9 #define rep1(i,a,b) for(int i=a;i<=b;++i) 10 #define rep0(i,a,b) for(int i=a;i<b;++i) 11 #define eps 1e-8 12 #define int_inf 0x3f3f3f3f 13 #define ll_inf 0x7f7f7f7f7f7f7f7f 14 #define lson curpos<<1 15 #define rson curpos<<1|1 16 /* namespace */ 17 using namespace std; 18 /* header end */ 19 20 const int maxn = 1e4 + 10; 21 int n, m, tot1 = 0, tot2 = 0, c[maxn], vis[maxn]; 22 ll ans = 0; 23 24 struct Vert { 25 int x, y, xx; 26 bool operator<(const Vert &rhs)const { 27 return y < rhs.y; 28 } 29 } v[maxn]; 30 31 struct Hori { 32 int x, y, yy; 33 bool operator<(const Hori &rhs)const { 34 return yy < rhs.yy; 35 } 36 } h[maxn]; 37 38 int lowbit(int x) { 39 return x & -x; 40 } 41 42 int find(int x) { 43 int ret = 0; 44 while (x > 0) { 45 ret += c[x]; 46 x -= lowbit(x); 47 } 48 return ret; 49 } 50 51 void add(int x, int val) { 52 while (x <= 10001) { 53 c[x] += val; 54 x += lowbit(x); 55 } 56 } 57 58 int main() { 59 scanf("%d", &n); 60 rep1(i, 1, n) { 61 int x, y, xx, yy; scanf("%d%d%d%d", &x, &y, &xx, &yy); 62 x += 5001, y += 5001, xx += 5001, yy += 5001; 63 if (x == xx) h[++tot2] = (Hori) { 64 x, min(y, yy), max(y, yy) 65 }; 66 else v[++tot1] = (Vert) { 67 min(x, xx), y, max(x, xx) 68 }; 69 } 70 sot(v, tot1); sot(h, tot2); 71 sort(v + 1, v + 1 + tot1); 72 sort(h + 1, h + 1 + tot2); 73 rep1(i, 1, tot1) { 74 rep0(j, 0, maxn) c[j] = 0; 75 rep1(j, 1, tot2) { 76 if (h[j].y <= v[i].y && h[j].yy >= v[i].y) { 77 add(h[j].x, 1); 78 vis[j] = 1; 79 } else vis[j] = 0; 80 } 81 int k = 1; 82 rep1(j, i + 1, tot1) { 83 while (k <= tot2 && h[k].yy < v[j].y) { 84 if (vis[k]) add(h[k].x, -1); 85 k++; 86 } 87 int l = max(v[i].x, v[j].x) - 1, r = min(v[i].xx, v[j].xx); 88 if (l < r) { 89 int x = find(r) - find(l); 90 ans += 1LL * x * (x - 1) / 2; 91 } 92 } 93 } 94 printf("%lld\n", ans); 95 return 0; 96 }
View Code
F && G:
不会,溜了(
转载于:https://www.cnblogs.com/JHSeng/p/11190004.html
Codeforces Edu Round 68 (Rated for Div. 2)相关推荐
- Educational Codeforces Round 68 (Rated for Div. 2)-D. 1-2-K Game
output standard output Alice and Bob play a game. There is a paper strip which is divided into n + 1 ...
- Codeforces Edu Round 64 (Rated for Div. 2)
本来在快乐写题的,突然A数据炸了,全场重测,unrated-- 昨晚的题也有点毒,不过总体来说还算简单. A: 一开始我也wa on 3了,仔细想想就会发现有重点的情况. 比如n==3, 3 1 2. ...
- Educational Codeforces Round 90 (Rated for Div. 2)(A, B, C, D, E)
Educational Codeforces Round 90 (Rated for Div. 2) Donut Shops 思路 分三种情况: a==c/ba == c / ba==c/b这个时候两 ...
- Educational Codeforces Round 114 (Rated for Div. 2) (A ~ F)全题解
整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 Educational Codeforces Round 114 (Rated for Div. 2) ...
- Educational Codeforces Round 106 (Rated for Div. 2)(A ~ E)题解(每日训练 Day.16 )
整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 目录 Educational Codeforces Round 106 (Rated for Div. ...
- Educational Codeforces Round 37 (Rated for Div. 2) 1
Educational Codeforces Round 37 (Rated for Div. 2) A.Water The Garden 题意:Max想给花园浇水.花园可被视为长度为n的花园床,花园 ...
- Educational Codeforces Round 89 (Rated for Div. 2)(A, B, C, D)
Educational Codeforces Round 89 (Rated for Div. 2) A. Shovels and Swords 思路 题意非常简单,就是得到最多的物品嘛,我们假定a, ...
- Educational Codeforces Round 114 (Rated for Div. 2) D. The Strongest Build 暴力 + bfs
传送门 文章目录 题意: 思路: 题意: 你有nnn个装备槽,每个槽里面有cic_ici个力量加成,对于每个槽只能选一个力量加成,现在给你mmm个力量组合[b1,b2,...,bn][b_1,b_2 ...
- Educational Codeforces Round 72 (Rated for Div. 2) D. Coloring Edges dfs树/拓扑找环
传送门 文章目录 题意: 思路: 题意: 给你一张图,你需要给这个图的边染色,保证如果有环那么这个环内边的颜色不全相同,输出染色方案和用的颜色个数. n,m≤5e3n,m\le5e3n,m≤5e3 思 ...
最新文章
- GDALWarp设置GDALWarpOptions::dfWarpMemoryLimit过大时处理失败
- 批处理-取年月日、时分秒毫秒
- 高级停靠(Dock)技术的实现
- 看完后,我才明白 Redis 为什么默认 16 个数据库?
- 博士申请 | 约翰霍普金斯大学招收2022年入学trustworthy AI方向博士生
- 计算机应用基础随堂,《计算机应用基础》随堂题库
- Rustup 管理工具
- javascript获取浏览器客户端IP
- python有多少种语法_这20个常规Python语法你都搞明白了吗?
- 2021年中国仪表阀市场趋势报告、技术动态创新及2027年市场预测
- IDEA 中创建多级目录
- python 递归函数_Python教程系列之递归函数与匿名函数调用
- java循环打印三角形_Java for循环打印三角形(基础)
- linux 看rabbit版本,Linux下安装rabbitMq
- 【Multisim仿真】数字电路仿真16路往复流水灯
- html调用矢量小图标的方法,微信小程序里引入SVG矢量图标的方法
- 打通C到B,“能者多劳”的小冰
- 7-8 jmu-Java-03面向对象-06-继承覆盖综合练习-Person、Student、Employee、Company
- 大学计算机课英语心得体会,【大学计算机课程总结12篇】_大学计算机课程总结范文大全_2021年大学计算机课程总结_东城教研...
- Flutter--使用相机
热门文章
- linux上安装osg_如何在 Linux 上安装并启用 Flatpak 支持? | Linux 中国
- python实现简单的http服务器_python实现简单http服务器功能
- thinkpad键盘功能键驱动_韩度X-104机械键盘拆解评测 - 性价之选
- yolov5继续训练_震惊! 它来了!YOLOv5它来了!
- reactor线程模型_面试一文搞定JAVA的网络IO模型
- 学习了pr后的收获_零基础如何学习PR影视剪辑以及调色?
- 怀仁一中计算机等级考试网页,2021年度初中计算机等级考试理论复习题.doc
- grpc(3):使用 golang 开发 grpc 服务端和client
- centos升级默认node版本
- 云服务器真假辨别奥秘