Codeforces Round #685 (Div. 2)
待补
A
#include <bits/stdc++.h>
using namespace std;
int n;
int main()
{
int __;
scanf("%d", &__);
while(__ -- )
{
scanf("%d", &n);
if(n == 1) printf("0\n");
else if(n == 2) printf("1\n");
else if(n == 3) printf("2\n");
else if(n % 2 == 0) printf("2\n");
else printf("3\n");
}
return 0;
}
B
#include <bits/stdc++.h>
using namespace std;
const int N = 100 + 20;
int n, q;
char str[N];
int main()
{
int __;
scanf("%d", &__);
while(__ -- )
{
scanf("%d%d", &n, &q);
scanf("%s", str + 1);
while(q -- )
{
int l, r;
scanf("%d%d", &l, &r);
int flag = 0;
for(int i = 1; i < l; ++ i)
if(str[i] == str[l])
flag = 1;
for(int i = r + 1; i <= n; ++ i)
if(str[i] == str[r])
flag = 1;
if(flag) printf("YES\n");
else printf("NO\n");
}
}
return 0;
}
C
#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 10;
int n, k;
char a[N], b[N];
int ca[30], cb[30];
int main()
{
int __;
scanf("%d", &__);
while(__ -- )
{
for(int i = 0; i < 26; ++ i)
ca[i] = cb[i] = 0;
scanf("%d%d", &n, &k);
scanf("%s%s", a + 1, b + 1);
for(int i = 1; i <= n; ++ i) ca[a[i] - 'a'] ++;
for(int i = 1; i <= n; ++ i) cb[b[i] - 'a'] ++;
int flag = 0;
for(int i = 0; i < 26; ++ i)
{
if(ca[i] < cb[i]) { flag = 1; break;}
if((ca[i] - cb[i]) % k == 0)
ca[i + 1] = ca[i + 1] + ca[i] - cb[i];
else {flag = 1; break;}
}
if(flag) puts("No");
else puts("Yes");
}
return 0;
}
D
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL d, k;
int main()
{
int __;
scanf("%d", &__);
while(__ -- )
{
scanf("%lld%lld", &d, &k);
LL x = 0, y = 0, res = 0;
while(x * x + y * y <= d * d)
{
if(x < y) x += k;
else y += k;
res ++;
}
if(res % 2 == 0) puts("Ashish");
else puts("Utkarsh");
}
return 0;
}
E1/E2
#include <bits/stdc++.h>
using namespace std;
const int N = 1 << 17;
int n, v[N], from[N], a[N];
int query(int op, int i, int j)
{
if(op == 1) printf("AND");
if(op == 2) printf("XOR");
printf(" %d %d\n", i, j); fflush(stdout);
int x;
scanf("%d", &x);
return x;
}
void print()
{
printf("!");
for(int i = 1; i <= n; ++ i) printf(" %d", a[i]);
puts("");
}
void f(int x, int y)
{
a[x] = a[y] = query(1, x, y);
a[1] = v[x] ^ a[x];
for(int i = 2; i <= n; ++ i)
a[i] = a[1] ^ v[i];
print();
}
void g(int x, int y)
{
int v1 = query(1, 1, x);
int v2 = query(1, 1, y);
for(int i = 0; i < 16; ++ i)
{
int u = 0;
if(i == 0) u = (v2 >> i) & 1;
else u = (v1 >> i) & 1;
a[1] |= u << i;
for(int j = 2; j <= n; ++ j)
a[j] |= (u ^ ((v[j] >> i) & 1)) << i;
}
print();
}
int main()
{
scanf("%d", &n);
for(int i = 2; i <= n; ++ i) v[i] = query(2, 1, i);
for(int i = 2; i <= n; ++ i)
if(!v[i]) { f(1, i); return 0; }
for(int i = 2; i <= n; ++ i)
if(!from[v[i]]) from[v[i]] = i;
else { f(from[v[i]], i); return 0; }
g(from[1], from[2]);
return 0;
}
2020.11.23
Codeforces Round #685 (Div. 2)的更多相关文章
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #368 (Div. 2)
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
- Codeforces Round #279 (Div. 2) ABCDE
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name A Team Olympiad standard input/outpu ...
- Codeforces Round #262 (Div. 2) 1003
Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 2 ...
- Codeforces Round #262 (Div. 2) 1004
Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory lim ...
- Codeforces Round #371 (Div. 1)
A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给 ...
- Codeforces Round #268 (Div. 2) ABCD
CF469 Codeforces Round #268 (Div. 2) http://codeforces.com/contest/469 开学了,时间少,水题就不写题解了,不水的题也不写这么详细了 ...
随机推荐
- echart关系图平分节点删除时自动平衡问题
项目场景: 项目场景:Echarts关系图中(不是力图)一个节点x,y是固定的,为了同一列能居中显示,规定:当前列有奇数个元素新节点往下放,有偶数个节点时新节点往上放. 问题描述: 删除中间节点会有空 ...
- Cobbler自定义安装系统和私有源
1.自定义安装系统(根据mac地址) --name=定义名称 --mac=客户端的mac地址 --ip-address=需求的ip --subnet=掩码 --gateway=网关 --interfa ...
- codeforces 1045I Palindrome Pairs 【stl+构造】
题目:戳这里 题意:给1e5个字符串,问有多少对字符串组合,满足最多只有一种字符有奇数个. 解题思路:每种情况用map存一下就行了.感觉这题自己的代码思路比较清晰,所以写个题解记录一下 附ac代码: ...
- 2018ACM上海大都会赛 F Color it【基础的扫描线】
题目:戳这里 题意:有n*m个点全为白色,q个圆,将q个圆内所有的点都染成黑色,问最后剩下多少白色的点. 解题思路:每一行当做一个扫描线,扫描所有的圆,记录每一行在圆中的点即可,O(n*q). 附ac ...
- 初学算法之最基础的stl队列
简记为先进先出(first in first out) 它只允许在表的前端(front)进行删除操作,而在表的后端(rear)进行插入操作. 实用: #include <queue>//头 ...
- Leetcode(870)-优势洗牌
给定两个大小相等的数组 A 和 B,A 相对于 B 的优势可以用满足 A[i] > B[i] 的索引 i 的数目来描述. 返回 A 的任意排列,使其相对于 B 的优势最大化. 示例 1: 输入: ...
- spring-cloud-netflix-config
Spring Cloud Config 在我们了解spring cloud config之前,我可以想想一个配置中心提供的核心功能应该有什么 提供服务端和客户端支持 集中管理各环境的配置文件 配置文件 ...
- js & while & do while
js & while & do while https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Stat ...
- idle & js
idle & js idle meaning in js https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensi ...
- 新年狂欢高倍币,1万枚VAST拿到手软
新一年NGK推出了新币VAST,成为了当前最瞩目的一颗星.有人认为VAST有价无市,有人认为VAST价值巨大,潜力无限.总之,众说风云! 选择数字货币,当然是挑选有价值的货币,从内外价值入手. 一.币 ...