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 码了. 不幸 ...
随机推荐
- 基于OpenAi通用特定领域的智能语音小助手
无穷尽的Q&A 钉钉...钉钉... 双双同学刚到工位,报销答疑群的消息就万马纷沓而来.她只能咧嘴无奈的摇摇头.水都还没有喝一口就开始"人工智能"的去回复.原本很阳光心情开 ...
- 关于win11系统修改用户名导致登录进入不了系统的坑
背景:公司的新电脑,win11系统,开机进入需要注册用户名和密码,在取用户名的时候,手快没注意取了一个中文名,结果这给我后面的工作带来了一个坑,我在用mysqlworkbench进行数据备份,需要对数 ...
- [ARC160F] Count Sorted Arrays
Problem Statement There are an integer $N$ and $M$ pairs of integers: $(a_1, b_1), (a_2, b_2), \dots ...
- C#设计模式之享元模式(Flyweight)
using System; using System.Collections; public class Client { public static void Main(string[] args) ...
- Swagger配置类
Swagger配置类 package com.guoba.servicebase.config; import com.google.common.base.Predicates; import or ...
- Oracle数据库运维场景下,智能运维如何落地生根?
简介: 「智能运维大数据平台」是一款开箱即用的运维监控平台,通过特有的平台功能可以将企业的基础架构.应用程序.日志管理结合在一起,提供统一采集.统一存储.关联分析.统一监控企业业务保障能力,保障企业业 ...
- Supershell防溯源反制配置
简介 项目地址:https://github.com/tdragon6/Supershell Supershell是一个集成了reverse_ssh服务的WEB管理平台,使用docker一键部署(快速 ...
- 一些JavaSE学习过程中的思路整理(四)(主观性强,持续更新中...)
目录 一些JavaSE学习过程中的思路整理(四)(主观性强,持续更新中...) 多线程编程:资源类&任务&运行机制的解耦合 关于重入锁(ReentrantLock)的细节 条件对象配合 ...
- Spring系列:基于注解的方式构建IOC
目录 一.搭建子模块spring6-ioc-annotation 二.添加配置类 三.使用注解定义 Bean 四.@Autowired注入 五.@Resource注入 六.全部代码 从 Java 5 ...
- ChatGPT新玩法来了,微信聊天机器人
前言 上一篇文章中说了ChatGPT是什么,然后怎么注册使用. 传送门:花了1块钱体验一把最近很火的ChatGPT 但是实际操作下来还是有不少小伙伴跟我一样遇到各种坑. 没有魔法工具 OpenAI的服 ...