Codeforces Round #664 题解(A ~ C)
1395A - Boboniu Likes to Color Balls
如果在r,b,g,w中小于或等于一个奇数,则可以将其定为回文。
否则,请进行一次操作(如果可以),然后检查上述情况。
进行多次操作是没有意义的,因为我们只关心r,b,g,w的奇偶性
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll r, g, b, w;
int main() {
//freopen("in.txt", "r", stdin);
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int t; cin >> t; while (t--) {
cin >> r >> g >> b >> w;
ll c = r + g + b + w;
int cnt = (r & 1) + (g & 1) + (b & 1);
if (cnt == 0 || cnt == 3)cout << "Yes" << endl;
else if(c & 1){
if (cnt == 2 && r && g && b)w += 3, cnt = 1;
if (cnt == 2) cout << "No\n";
else if (w & 1) cout << "No\n";
else cout << "Yes" << endl;
} else cout << "No" << endl;
}
}
1395B - Boboniu Plays Chess
假设\(f(i,j) =((i + Sx-2)modn + 1, (j + Sy-2)mod (m + 1))\)。
将i从1迭代到n:如果i为奇数,则打印\(f(i,1),f(i,2),…,f(i,m)\)。
否则打印\(f(i,m),f(i,m-1),…,f(i,1)\)。
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100;
int n, m, a, b;
bool row[maxn + 3], vis[maxn + 3][maxn + 3];
int main() {
scanf("%d %d %d %d", &n, &m, &a, &b);
for (int i = 1; i <= n; i++) {
if (i > 1) for (int j = 1; j <= n; j++) if (!row[j]) { a = j; break; }
row[a] = true;
printf("%d %d\n", a, b);
vis[a][b] = true;
for (int j = 1; j < m; j++) {
for (int k = 1; k <= m; k++) if (!vis[a][k]) { b = k; break; }
printf("%d %d\n", a, b);
vis[a][b] = true;
}
}
return 0;
}
1395C - Boboniu and Bit Operations
假设答案为A。因此,对于所有\(i(1≤i≤n),c_i | A = A\)。
由于\(a_i,b_i <2^9\),我们可以枚举从\(0到2^9-1\)的所有整数,并检查每个i是否存在\(j(ai&bj)| A = A\)。 最少的就是答案。
时间复杂度为\(O(2^9⋅n^2\))
#include<bits/stdc++.h>
#define ci const int&
using namespace std;
int n,m,p[210],d[210],ans;
bool Check(ci x){
for(int i=1;i<=n;++i){
for(int j=1;j<=m;++j)if(((p[i]&d[j])|x)==x)goto Next;
return 0;
Next:;
}
return 1;
}
int main(){
scanf("%d%d",&n,&m);
for(int i=1;i<=n;++i)scanf("%d",&p[i]);
for(int i=1;i<=m;++i)scanf("%d",&d[i]);
ans=(1<<9)-1;
for(int i=8;i>=0;--i)Check(ans^(1<<i))?ans^=(1<<i):0;
printf("%d",ans);
return 0;
}
Codeforces Round #664 题解(A ~ C)的更多相关文章
- Codeforces Round #556 题解
Codeforces Round #556 题解 Div.2 A Stock Arbitraging 傻逼题 Div.2 B Tiling Challenge 傻逼题 Div.1 A Prefix S ...
- Codeforces Round #569 题解
Codeforces Round #569 题解 CF1179A Valeriy and Deque 有一个双端队列,每次取队首两个值,将较小值移动到队尾,较大值位置不变.多组询问求第\(m\)次操作 ...
- Codeforces Round #557 题解【更完了】
Codeforces Round #557 题解 掉分快乐 CF1161A Hide and Seek Alice和Bob在玩捉♂迷♂藏,有\(n\)个格子,Bob会检查\(k\)次,第\(i\)次检 ...
- CFEducational Codeforces Round 66题解报告
CFEducational Codeforces Round 66题解报告 感觉丧失了唯一一次能在CF上超过wqy的机会QAQ A 不管 B 不能直接累计乘法打\(tag\),要直接跳 C 考虑二分第 ...
- Codeforces Round #542 题解
Codeforces Round #542 abstract I决策中的独立性, II联通块染色板子 IIIVoronoi diagram O(N^2 logN) VI环上距离分类讨论加取模,最值中的 ...
- Educational Codeforces Round 19 题解【ABCDE】
A. k-Factorization 题意:给你一个n,问你这个数能否分割成k个大于1的数的乘积. 题解:因为n的取值范围很小,所以感觉dfs应该不会有很多种可能-- #include<bits ...
- Codeforces-Educational Codeforces Round 53题解
写之前,先发表下感慨:好久没写题解了,也许是因为自己越来越急利了,也可以说是因为越来越懒了. A. Diverse Substring 直接找一找有没有相邻的两个不同的字符即可. B. Vasya a ...
- Codeforces Round #519 题解
A. Elections 题意概述 给出 \(a_1, \ldots, a_n\),求最小的 \(k (k \ge \max a_i)\), 使得 \(\sum_{i=1}^n a_i < \s ...
- Codeforces Round #397 题解
Problem A. Neverending competitions 题目大意 一个团队有多个比赛,每次去比赛都会先订机票去比赛地点,然后再订机票返回.给出\(n\)个含有起止地点的购票记录(不按时 ...
- Codeforces Round 596 题解
万幸的是终于碰上了一场上分好场. 不幸的是一开始差点不会 A. 万幸的是想了个不那么稳的结论过了 pretest. 不幸的是罚时很高,而且慌得一比. 万幸的是然后半个小时内把 B 和 C 码了. 不幸 ...
随机推荐
- 新手VSCode配置C++20
最近买了本C++20的书,想要自己配置下在VScode的环境 例子代码: #include <iostream> #include <format> int main() { ...
- 飞腾E2000板载以太网适配
飞腾E2000板载以太网适配 e20005.4.18macbyt8521 1. 设备树移植 2. MACB驱动移植 3. 网络连通性调试 3-1. MACB驱动环回测试 3-2. YT8521 PHY ...
- 【报错:For input string: ""报错: get connection error! 报错:java.lang.NullPointerException 报错:java.lang.NumberFormatException: For input string: "id"】解决方案
原因:没有input数据进入,但是当我填写数据进入的时候 get connection error! 这个消息,是我要抛出去的异常,源代码下 我一开始觉得是代码书写的问题,找.......... 应该 ...
- Centos8.4自定义离线安装Nginx
一.简介 Nginx是一个web服务器也可以用来做负载均衡及反向代理使用. 目前使用最多的就是负载均衡,这篇文章主要介绍了centos8 安装 nginx. Nginx是一种开源的高性能HTTP和反向 ...
- MongoDB (操作数据库,操作集合,操作文档)的笔记
https://www.bilibili.com/video/BV1gV411H7jN/?spm_id_from=333.999.0.0&vd_source=92305fa48ea41cb7b ...
- Lucene和索引
全文索引的原理: 是 扫描每个词 对每个词创建索引,指明这个词在文章出现的次数和位置 全文检索的流程:对 检索的对象(文章,文档,网页内容) 预先建立 文档域 和 索引域 ,在索引域会分词创建索引,然 ...
- 自定义线程池将异常"吃了"
今天在做项目时,写了一个使用自定义线程池执行远程调用 // 删除购物车信息 corePoolExecutor.submit(() -> { try { cartFeignClient.delet ...
- Feign远程调用丢失请求头问题
问题 项目中我使用feign进行远程调用时,在请求头设置了参数(UserId),结果在调用方却收获取不到... 解决办法 feign提供了一个拦截器,在远程调用之前执行 核心代码 package co ...
- django分页器使用
https://docs.djangoproject.com/en/3.2/topics/pagination/ Django 提供了高级和低级方法来帮助您管理分页数据--即,分成多个页面的数据,并带 ...
- 华企盾防泄密软件关于U盘无法注册问题
1.以管理员权限运行控制台注册 2.如果是非加密注册可在USB拔插日志中右键日志远程注册 3.检查USB的驱动程序注册表是否都有 4.换一台电脑安装控制台注册 5.检查是否有与驱动有关的程序卸载试试 ...