Codeforces Round #770 (Div. 2) ABCD题解
A. Reverse and Concatenate
#define sf(x) scanf("%d",&x)
#define all(x) (x).begin(),(x).end()
#define cf int _; cin>> _; while(_--)
inline void sf2(int &a , int &b) { sf(a) , sf(b) ;}
signed main()
{cf{int n , m ;sf2(n, m);string s;cin >> s;string ans = s;reverse(all(s));if (s != ans && m)puts("2");elseputs("1");}return 0;
}
B. Fortune Telling
思路:
注 意 到 x 和 x + 3 奇 偶 性 不 同 注意到x和x+3奇偶性不同 注意到x和x+3奇偶性不同
#define fer(i,a,b) for(int i = a ; i <= b ; ++ i)
#define cf int _; cin>> _; while(_--)
const int N = 1e6 + 10 ;
int n ;
int a[N] , x , y ;signed main()
{cf{cin >> n >> x >> y ;int cnt = 0 ;fer(i,1,n){sf(a[i]) ;if(a[i] & 1) cnt ++ ;}if(x & 1){if(y & 1){if(cnt % 2 == 0) puts("Alice") ;else puts("Bob") ;}else{if(cnt % 2) puts("Alice") ;else puts("Bob") ;}}else {if(y & 1){if(cnt % 2 == 0) puts("Bob") ;else puts("Alice") ;}else{if(cnt % 2) puts("Bob") ;else puts("Alice") ;}}}return 0;
}
C. OKEA
#define fer(i,a,b) for(int i = a ; i <= b ; ++ i)
#define cf int _; cin>> _; while(_--)
signed main()
{cf{int n , k ;cin >> n >> k ;if(n % 2 == 0){puts("YES") ;int cnt = 0 ;for(int i = 1 ; i <= n * k ; i += 2){cnt ++ ;cout << i << " " ;if(cnt == k){cnt = 0 ;puts("") ;}}for(int i = 2 ; i <= n * k ; i += 2){cnt ++ ;cout << i << " " ;if(cnt == k){cnt = 0 ;puts("") ;}}}else if(k <= 1){puts("YES") ;if(k == 1){fer(i,1,n*k){cout << i << "\n" ;}}}else puts("NO") ;}return 0;
}
D. Finding Zero
同 理 , 第 二 次 循 环 替 换 掉 第 二 个 数 同理,第二次循环替换掉第二个数 同理,第二次循环替换掉第二个数
同 时 更 新 l a s t 同时更新last 同时更新last
同 理 当 前 差 值 ! = l a s t , 那 就 用 i d 替 换 y / z 同理当前差值!=last,那就用id替换y/z 同理当前差值!=last,那就用id替换y/z
#define cf int _; cin>> _; while(_--)
signed main()
{cf{int n ;cin >> n ;int x = 1 , y = 2 , z = 3 ;int last ;cout << "? " << x << " " << y << " " << z << '\n' ;cout.flush() ;cin >> last ;for(int i = 4 ; i <= n ; i ++){cout << "? " << x << " " << y << " " << i << '\n' ;cout.flush() ;int k ;cin >> k ;if(k >= last){last = k ;z = i ;}}for(int i = 1 ; i <= n ; i ++){if(i == x || i == y || i == z) continue ;cout << "? " << x << " " << i << " " << z << '\n' ;cout.flush() ;int k ;cin >> k ;if(k >= last){last = k ;y = i ;}}int id = -1 ;for(int i = 1 ; i <= n ; i ++){if(i == x || i == y || i == z) continue ;id = i ;break ;}int k ;cout << "? " << id << " " << y << " " << z << '\n' ;cout.flush() ;cin >> k ;if(k == last){cout << "! " << y << " " << z << "\n" ;}else {cout << "? " << x << " " << id << " " << z << '\n' ;cout.flush() ;cin >> k ;if(k == last){cout << "! " << x << " " << z << "\n" ;}else{cout << "? " << x << " " << y << " " << id << '\n' ;cout.flush() ;cin >> k ;if(k == last){cout << "! " << x << " " << y << "\n" ;}else cout << "! " << x << " " << y << "\n" ;}}}return 0;
}
Codeforces Round #770 (Div. 2) ABCD题解相关推荐
- Codeforces Round #250 (Div. 2) (ABCD题解)
比赛链接:http://codeforces.com/contest/437 A. The Child and Homework time limit per test:1 second memory ...
- Codeforces Round #777 (Div. 2) ABCD题解
A-Madoka and Math Dad 题目大意: 一个十进制数字(不含0),各个位上的和为n(n<=1000),且相邻位没有相同的数字,问这个数字最大可以是多少. 思路: 显然要使这个数字 ...
- Codeforces Round #695 (Div. 2)ABCD题解详析
A. Wizard of Orz 首先保证第一块板子是999,那么第二块板子不可能是999,那么令第二块板子为888 只要在第二块板到达888的时候按下暂停,那么第一块是999,第三块板子也是999 ...
- Codeforces Round #686 (Div. 3) A-F题解
Codeforces Round #686 (Div. 3) A-F题解 A. Special Permutation 题意 给定 nnn ,输出一个长度为 nnn 的全排列,每个位置 iii 上的数 ...
- Codeforces Round #693 (Div. 3)部分题解
Codeforces Round #693 (Div. 3) 部分题解 D. Even-Odd Game 思路: 贪心:田忌赛马 (1)先将数组从大到小排序,取数时从大到小取,用一个ans变量记录取数 ...
- Codeforces Round #702 (Div. 3)A-G题解
Codeforces Round #702 (Div. 3)A-G题解 比赛链接:https://codeforces.ml/contest/1490 这场F读错题意白给一发,G二分的if(dp[mi ...
- codeforces Round #645 (Div. 2)D题解
Codeforces Round #645 (Div. 2)--D题解 作为一名菜鸡,理所当然得没有A出来,这道题数据放小就一水题了,可惜数据这块卡的死死的. 本题最重要的一点就是你要推出来一个结论: ...
- Codeforces Round #670 (Div. 2)A-D题解
Codeforces Round #670 (Div. 2)A-D题解 //写于rating值1987/2184 //补档 比赛链接:https://codeforces.ml/contest/140 ...
- Codeforces Round #674 (Div. 3)A-F题解
Codeforces Round #674 (Div. 3)A-F题解 比赛链接:https://codeforces.com/contest/1426 A题 水题不写题解 #include<b ...
最新文章
- 应用程序模块和实体缓存
- linux 命令行 解密,解密Linux终端命令 学好Linux
- 数据结构与算法 Python语言描述 笔记
- 知乎神回复:普通程序员一天的工作生活是怎样的?网友实名羡慕!
- uploadify 3.1 /3.2 在Firefox,Chrome 浏览器下,进入页面请求两次问题解决办法。
- spring mvc controller间跳转 重定向 传参 (转)
- 【NumPy基础】100道numpy练习——进阶篇
- Hive调优全方位指南(推荐收藏)
- ipad下载python_ipad python
- 夏普Sharp AR-6120N 一体机驱动
- 直播预告 | 自监督学习在推荐系统中的应用
- SpringBoot系列之集成EasyExcel导入合并行数据
- [计算机网络]网络层
- pycharm永久激活
- DMA+PWM驱动彩色RGB灯
- amp模式_AMP的完整形式是什么?
- kruskal算法实现 —c++ 最小k生成森林问题 cs精英挑战营 柿子问题
- 服务器开超线程性能提升多少,超线程能提升处理器效率
- 登陆进管理后台的首页
- android Matrix的invert实现
热门文章
- 已经发车的票还能取出来吗_我买了张高铁票(已付过钱),但是车已经开了,我没上车,票也没取,还能在取出票吗?...
- 【IoT】CC254x 中 data、idata、xdata 和 pdata 区别以及堆 Heap 内存布局
- How I built a wind map with WebGL 源码理解(没完)
- Android自定义控件进阶13-MotionEvent详解
- 王爽《汇编语言》读书笔记——第二章
- 操作系统资源的最大限制(1)
- C语言实现学生成绩管理系统(原码)
- 8.18 B组 T1 分火腿
- 上位机与嵌入式下位机等效控制原理
- php设置二级域名泛解析,泛域名解析配合.htaccess实现二级域名功能