当前位置:网站首页>Codeforces Round #810 (Div. 2) A - C
Codeforces Round #810 (Div. 2) A - C
2022-07-28 21:50:00 【追烽】
Codeforces Round #810 (Div. 2)
提交情况

参考
Codeforces Round #810 (Div. 1 + Div. 2) 2A - 2D
Codeforces Round #810 (Div. 2)(A - C)
A. Perfect Permutation
标签
构造
题意

思路
相邻的数互质。
代码
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define ROF(i,a,b) for(int i=(a);i>=(b);--i)
#define mem(a) memset((a),0,sizeof(a))
#define endl '\n'
// #define int long long
using namespace std;
const int N = 2e5+7;
void solve(){
int n; cin>>n;
if(n>1) cout<<2<<" ";
FOR(i,2,n-1) cout<<i+1<<" ";
cout<<1<<endl;
}
signed main(){
cin.tie(0)->sync_with_stdio(0);
int T=1; cin>>T;
while(T--) solve();
return 0;
}
B. Party
标签
构造
题意

注意只有一对朋友会吃掉一个蛋糕,单个人不会吃蛋糕。
思路

代码
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define ROF(i,a,b) for(int i=(a);i>=(b);--i)
#define mem(a) memset((a),0,sizeof(a))
#define PII pair<int,int>
#define endl '\n'
// #define int long long
using namespace std;
const int N = 2e5+7;
int a[N],e[N];
PII p[N];
void solve(){
mem(e);
int n,m; cin>>n>>m;
FOR(i,1,n) cin>>a[i];
FOR(i,1,m){
int x,y; cin>>x>>y;
p[i]={
x,y};
e[x]++,e[y]++;
}
if(m%2==0) {
cout<<"0\n"; return ;}
int ans=2e9;
FOR(i,1,n) if(e[i]%2) ans=min(ans,a[i]);
FOR(i,1,m){
int x=p[i].first, y=p[i].second;
if(e[x]%2==0 and e[y]%2==0)
ans=min(ans,a[x]+a[y]);
}
cout<<ans<<endl;
}
signed main(){
cin.tie(0)->sync_with_stdio(0);
int T=1; cin>>T;
while(T--) solve();
return 0;
}
C. Color the Picture
标签
构造
题意


思路

代码
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define ROF(i,a,b) for(int i=(a);i>=(b);--i)
#define mem(a) memset((a),0,sizeof(a))
#define PII pair<int,int>
#define endl '\n'
#define int long long
using namespace std;
const int N = 2e5+7;
int a[N],kn[N],km[N],oddn,oddm;
void solve(){
oddn=0,oddm=0;
int n,m,k; cin>>n>>m>>k;
FOR(i,1,k) cin>>a[i];
int sumn=0,summ=0;
FOR(i,1,k){
kn[i]=a[i]/n;
if(kn[i]==1) kn[i]=0;
if(kn[i]>=3) oddn=1;
sumn+=kn[i];
km[i]=a[i]/m;
if(km[i]==1) km[i]=0;
if(km[i]>=3) oddm=1;
summ+=km[i];
}
if(sumn<m and summ<n) {
cout<<"No\n";return;}
if(sumn>=m){
if(m%2 and oddn) {
cout<<"Yes\n";return;}
if(m%2==0) {
cout<<"Yes\n";return;}
}
if(summ>=n){
if(n%2 and oddm) {
cout<<"Yes\n";return;}
if(n%2==0) {
cout<<"Yes\n";return;}
}
cout<<"No\n"; return;
}
signed main(){
cin.tie(0)->sync_with_stdio(0);
int T=1; cin>>T;
while(T--) solve();
return 0;
}
边栏推荐
- CV目标检测模型小抄(2)
- 「行泊一体」放量,福瑞泰克高性能域控制器领跑新赛道
- Win11快捷复制粘贴不能用怎么办?Win11快捷复制粘贴不能用
- 2022年R2移动式压力容器充装考题模拟考试平台操作
- 智能电视与小程序的结合
- Solve the exception that all control files are damaged
- Solve the problem of using anonymous users in pod due to the failure of attaching ciphertext token files for serviceaccount user authentication
- 1314_串口技术_RS232通信基础的信息
- trivy【3】自定义扫描策略
- 22牛客多校day1 I - Chiitoitsu 概论dp
猜你喜欢

Huawei wireless device configuration uses WDS technology to deploy WLAN services

苹果官网正在更新维护 Apple Store,国行 iPhone 13 / Pro 等产品将最高优惠 600 元

Win11快捷复制粘贴不能用怎么办?Win11快捷复制粘贴不能用

2022年G2电站锅炉司炉考试题库模拟考试平台操作

With the "integration of driving and parking", freytek's high-performance domain controller leads the new track

XML modeling

Programmer growth Chapter 30: artifact of identifying true and false needs

ACM SIGIR 2022 | 美团技术团队精选论文解读

Intel data center GPU is officially shipped to provide strong computing power with openness and flexibility

Optimization and implementation of custom MVC
随机推荐
【自】-刷题-数组
二舅火了,全网刷屏,他凭什么能治好我的精神内耗?
英特尔数据中心GPU正式发货,以开放灵活提供强劲算力
字节8年女测试总监工作感悟—写给想转行或即将进入测试行业的女生们...
LabVIEW对VISA Write和Read函数的异步和同步
2022g3 boiler water treatment test simulation 100 questions simulation test platform operation
How to embed AI digital human function in VR panorama? Create a cloud experience
MySQL transaction and storage system
Pin mapping relationship of stm32f103c series single chip microcomputer under Arduino framework
1314_ Serial port technology_ Basic information of RS232 communication
Swift type attribute and its attentions
酒店预订系统数据库房间库存设计思路
Trivy [2] tool vulnerability scanning
trivy【2】工具漏洞扫描
Elements in the middle (one article is enough)
Object object
顶级“黑客”能厉害到什么地步?无信号也能上网,专家:高端操作!
二叉搜索树
机器学习问题笔记
零念科技完成Pre-A轮融资,推动智能驾驶平台软件国产替代