TOYOTA SYSTEMS Programming Contest 2021(AtCoder Beginner Contest 228) ABCD
A
题意:
- 有一个开关,每天s点开,t点关(可能在第2天或第n天),判断x点时开着还是关着。
思路:
- 按照是否需要隔夜分个类。
#include<bits/stdc++.h>
using namespace std;
int main(){int s, t, x;cin>>s>>t>>x;if(s<t){if(x>=s&&x<t)cout<<"Yes\n";else cout<<"No\n";}else{if(x>=t&&x<s)cout<<"No\n";else cout<<"Yes\n";}return 0;
}
B、
题意:
- 高桥有n个朋友,每个朋友会向a[i]分享秘密,最开始s知道了秘密,求最后多少人会知道秘密。
思路:
- 开个set维护知道秘密的人,链式遍历即可。
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5+10;
int a[maxn];
int main(){int n, s;cin>>n>>s;for(int i = 1; i <= n; i++){cin>>a[i];}set<int>se;int now = s;for(int i = 1; i <= n; i++){if(i!=1 && now==s)break;se.insert(now);now = a[now];}cout<<se.size()<<"\n";return 0;
}
C、
题意:
- n个学生参加为期4天的考试,每天300分,已知前三天分数。
- 求最后一天考完第i个学生能否到达前k名,名次定义为比他分数高的人数+1。
思路:
- 贪心策略是第i个学生最后一天300分,其他人都0分。
- 把前三天的总分从大到小排个序,每次去二分第i个学生的排名位置,判断是否在k名内。
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5+10;
int a[maxn], b[maxn];
bool cmp(int x, int y){return x>y;}
int main(){int n, k; cin>>n>>k;for(int i = 1; i <= n; i++){for(int j = 1; j <= 3; j++){int x; cin>>x; a[i] += x;}b[i] = a[i];}sort(b+1,b+n+1,cmp);for(int i = 1; i <= n; i++){int p = lower_bound(b+1,b+n+1,a[i]+300,greater<int>())-b;if(p<=k || a[i]+300>=1200)cout<<"Yes\n";else cout<<"No\n";// if(a[i]+300>=b[k])cout<<"Yes\n";// else cout<<"No\n";}return 0;
}
D、
题意:
- 初始一个空序列 a[0]到a[2^20],默认都是-1。
- Q个操作,操作1找到a[x]往后第一个不是-1的位置,改成时间戳。操作2询问a[x]的值。
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = (1<<20)-1;int fa[maxn+10];
void init(int n){for(int i = 0; i <= n; i++)fa[i]=i;}
int find(int x){return x==fa[x]?x:fa[x]=find(fa[x]);}
void merge(int x, int y){x=find(x);y=find(y);if(x!=y)fa[x]=y;}
int count(int n){int cnt=0; for(int i = 1; i <= n; i++)if(fa[i]==i)cnt++;return cnt;}LL v[maxn+10];int main(){init(maxn);memset(v,-1,sizeof(v));int q; cin>>q;while(q--){LL op, x; cin>>op>>x;if(op==1){int i = find(x&maxn);v[i] = x;fa[i] = find((i+1)&maxn);}else{cout<<v[x&maxn]<<"\n";}}return 0;
}
TOYOTA SYSTEMS Programming Contest 2021(AtCoder Beginner Contest 228) ABCD相关推荐
- Caddi Programming Contest 2021(AtCoder Beginner Contest 193) 题解
Caddi Programming Contest 2021(AtCoder Beginner Contest 193) A - Discount 打折浮点数除即可 B - Play Snuke 枚举 ...
- Atcoder TOYOTA SYSTEMS Programming Contest 2021(AtCoder Beginner Contest 228) B - Takahashi‘s Secret
题目链接:B - Takahashi's Secret (atcoder.jp) Problem Statement Takahashi has N friends. They have nickna ...
- Atcoder TOYOTA SYSTEMS Programming Contest 2021(AtCoder Beginner Contest 228) C - Final Day
题目链接:C - Final Day (atcoder.jp) Problem Statement N students are taking a 4-day exam. There is a 300 ...
- NEC Programming Contest 2021(AtCoder Beginner Contest 229) B - Hard Calculation
题目链接:B - Hard Calculation (atcoder.jp) Problem Statement You are given positive integers A and B. Le ...
- KYOCERA Programming Contest 2021 (AtCoder Beginner Contest 200) A~E 题解
ABC200/KYOCERA2021 A~E [A - Century](https://atcoder.jp/contests/abc200/tasks/abc200_a) 题目大意 输入格式 输出 ...
- Mynavi Programming Contest 2021 (AtCoder Beginner Contest 201) A~E 题解
ABC201/Mynavi2021 A~E [A - Tiny Arithmetic Sequence](https://atcoder.jp/contests/abc201/tasks/abc201 ...
- NEC Programming Contest 2021 (AtCoder Beginner Contest 229)
终于开始补提了 重点 : C, E的倒着算, F的染色,G的相邻的转换: B - Hard Calculation #include <iostream> #include <alg ...
- Caddi Programming Contest 2021(AtCoder Beginner Contest 193) F.Zebraness
题目链接 Problem Statement We have a grid with N horizontal rows and N vertical columns. Let (i,j) denot ...
- NOMURA Programming Contest 2021(AtCoder Regular Contest 121)
文章目录 A - 2nd Greatest Distance B - RGB Matching C - Odd Even Sort D - 1 or 2 E - Directed Tree F - L ...
最新文章
- 二叉树总结挺好的很好记忆
- 保姆级计算机视觉学习路线
- 给定一个整数序列,求中位数
- CPU瓶颈(五)--过度编译与不必要重复编译的解决方案
- 计算机流体力学:CFD
- 韩寒诉百度文库侵权案分析
- 金蝶EAS系统,供应链,即时库存查询,库存查询SQL脚本
- 用计算机弹起风了乐谱,光遇起风了乐谱简谱弹奏攻略 光遇怎么弹奏起风了
- 几种蓝屏分析及解决汇总
- Python自然语言处理——nltk库入门之文本分词(英文)
- 【yum】Peer cert cannot be verified or peer cert invalid
- 【SpringCloud】 - Feign 踩坑记录:404 ,调用不成功 , 接口定义规范 等问题记录
- 刚刚,联通和华为发布《5G车路协同白皮书》| 附下载
- 【JZ38 字符串的排列】
- python使用gdal读取tif经纬度
- UVA 1647 Computer Transformation
- x86_64汇编之三:x86_64汇编和x86_32汇编的区别
- 百度OCR API识别失败:Open api qps request limit reached 错误也许在这
- PTA寒假基础题训练(含解题思路)(下)
- 我的上半年“手相”-----“奔跑中的2015”
热门文章
- Python Flask Web 第八课 —— request 请求对象
- 图论(一)—— 基本概念
- Tricks(二十一)—— 随机数
- Python 基础—— operator 模块、functools
- 免费python网络课程-python网络课程
- python最适合做什么-python适合做什么开发_python未来发展怎么样
- 普通人学python有意义吗-普通人为什么要学习Python?
- python儿童入门视频-老男孩Python视频教程全套完整版!无偿分享~
- 谷歌云端语音识别助手手机版-Google云端语音识别app1.0.0 官方安卓版-东坡下载...
- 为什么李开复说科大讯飞不懂语音,99%的语音识别项目要死掉?