当前位置:网站首页>Codeforces Round #810 (Div. 2) A - C
Codeforces Round #810 (Div. 2) A - C
2022-07-28 23:43:00 【Chasing the beacon】
Codeforces Round #810 (Div. 2)
Submission

Reference resources
Codeforces Round #810 (Div. 1 + Div. 2) 2A - 2D
Codeforces Round #810 (Div. 2)(A - C)
A. Perfect Permutation
label
structure
The question

Ideas
Adjacent number coprime .
Code
#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
label
structure
The question

Notice that only one pair of friends will eat a cake , No one can eat cake .
Ideas

Code
#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
label
structure
The question


Ideas

Code
#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;
}
边栏推荐
- 22牛客多校day1 I - Chiitoitsu 概论dp
- 机器学习问题笔记
- Go 中的并发 Concurrency
- 2022t elevator repair examination questions and simulation examination
- Arduino UNO驱动合宙1.8‘TFT SPI屏幕示例演示(含资料包)
- 2022 simulated examination platform operation of hoisting machinery command examination questions
- Read the recent trends of okaleido tiger and tap the value and potential behind it
- Arduino uno driver universe 1.8 'TFT SPI screen example demonstration (including data package)
- Manufacturing steps of interactive slide screen in exhibition hall
- Design idea of room inventory in hotel reservation system database
猜你喜欢
随机推荐
Neglected smart TV applet field
Fundamental inquiry binary tree
金仓数据库KingbaseES 客户端编程接口指南 - ODBC (2. 概述)
2022G3锅炉水处理考试模拟100题模拟考试平台操作
Pin mapping relationship of stm32f103c series single chip microcomputer under Arduino framework
Achieve high throughput through Wi Fi 7 - insight into the next generation of Wi Fi physical layer
[self] - question brushing - string
经典双栈实现队列,注意遍历栈的判定条件修改。
ACM SIGIR 2022 | 美团技术团队精选论文解读
互动滑轨屏在展厅中应用的制作步骤
【自】-刷题-动态规划
The front mounted ADAS camera in parking increased by 54.15% year-on-year, with TOP10 suppliers taking the lead
XML modeling
[self] - question brushing - dynamic programming
猿人学第二十题
Why did "you" become a test / development programmer? The value of your existence
事件抽取文献整理(2018)
22牛客多校day1 I - Chiitoitsu 概论dp
集火全屋智能“后装市场”,真正玩得转的没几个
【自】-刷题-峰值





![[self] - brush questions set](/img/de/46582086addbe5465d658081516f4c.png)



