当前位置:网站首页>Codeforces round 810 (Div. 2) [competition record]
Codeforces round 810 (Div. 2) [competition record]
2022-07-26 13:23:00 【Addiction ۣۖ ิ ۣۖ ิ ۣۖ ิꦿ】
A. Perfect Permutation
n Even numbers ,i~i+1 Just switch positions in pairs ;
n For an odd number , Exchange anyway , There must be one that satisfies the divisible condition , So the first number doesn't move , Then even numbers can be exchanged in pairs !!!
#include <bits/stdc++.h>
using namespace std;
#define sc(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define ll long long
#define pb push_back
#define INF 0x3f3f3f3f
#define eps 1e-8
const int Max=2e5+5;
int main(){
int t;sc(t);
while(t--){
int n;sc(n);
if(n%2==1){
printf("1 ");
for(int i=2;i<=n;i+=2){
printf("%d %d ",i+1,i);
}
}else{
for(int i=1;i<=n;i+=2){
printf("%d %d ",i+1,i);
}
}
printf("\n");
}
}B. Party
Watch this question for half an hour during the competition , Sit for half an hour , What a strange solution , See you for the first time !!! Drop points ,T_T
m If it is an even number , Just choose all , The answer for 0!!!
m If it is an odd number , The more people you invite, the better , So don't invite someone to have an even number of relationships , All the rest are invited , At this time, there may be an odd number of relationships , So this is not the optimal situation , Therefore, we also need to consider not inviting a pair of friends , There are even relationships in addition to each other !!!
#include <bits/stdc++.h>
using namespace std;
#define sc(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define ll long long
#define pb push_back
#define INF 0x3f3f3f3f
#define eps 1e-8
const int Max=2e5+5;
int a[Max],sum[Max];
pair<int,int> mp[Max];
int main(){
int t;
sc(t);
while(t--){
int n;int m;
sc(n);sc(m);
for(int i=1;i<=n;i++) sc(a[i]),sum[i]=0;
int ans=1e9+5;
for(int i=1;i<=m;i++){
int u,v;sc(u);sc(v);
sum[u]++;
sum[v]++;
mp[i]=make_pair(u,v);
}
if(m%2==0) printf("0\n");
else{
for(int i=1;i<=n;i++){
if(sum[i]%2) ans=min(ans,a[i]);
}
for(int i=1;i<=m;i++){
if((sum[mp[i].first]+sum[mp[i].second])%2==0){
ans=min(ans,a[mp[i].first]+a[mp[i].second]);
}
}
printf("%d\n",ans);
}
}
}C. Color the Picture
This problem could have been solved , It's all wrong !!!
There are two situations , One is to put it vertically , For example , Another is to put it horizontally , Every time you put a color, pay attention to the number of rows or columns >=2, From small to large, just be greedy !!!
#include <bits/stdc++.h>
using namespace std;
#define sc(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define ll long long
#define pb push_back
#define INF 0x3f3f3f3f
#define eps 1e-8
const int Max=2e5+5;
ll a[Max];
int main(){
int t;sc(t);
while(t--){
ll n,m,k;sl(n);sl(m);sl(k);
for(int i=1;i<=k;i++){
sl(a[i]);
}
bool flag=false;
ll ans=0;
sort(a+1,a+1+k);
for(int i=1;i<=k;i++){
if(a[i]/n>=2){
if((m-(ans+a[i]/n))==1){
if(a[i]/n>2) ans+=(a[i]/n-1);
}
else ans+=a[i]/n;
}
}
if(ans>=m){
printf("YES\n");continue;
}
ans=0;
for(int i=1;i<=k;i++){
if(a[i]/m>=2){
if((n-(ans+a[i]/m))==1){
if(a[i]/m>2) ans+=(a[i]/m-1);
}
else ans+=a[i]/m;
}
}
if(ans>=n){
printf("YES\n");continue;
}else printf("NO\n");
}
}Terrible , Drop field , It seems that I haven't played well once !!!!!!! What can go out doesn't go out
边栏推荐
- B+树索引使用(9)分组、回表、覆盖索引(二十一)
- 基于Bézier曲线的三维造型与渲染
- Some practical operations of vector
- JSON数据传递参数&日期型参数传递
- B+ tree (3) clustered index, secondary index -- MySQL from entry to proficiency (XV)
- 子组件触发父组件自定义事件(defineEmits):子组件传值给父组件
- Learn about Pinia state getters actions plugins
- B+树(5)myISAM简介 --mysql从入门到精通(十七)
- pomerium
- How to build a customer-centric product blueprint: suggestions from the chief technology officer
猜你喜欢

Chat system based on webrtc and websocket

多线程使用不当导致的 OOM
Exploration on cache design optimization of community like business

基于ASP.NET的某高校学院档案管理系统

Unicode文件解析方法及存在问题

Slam 02. overall framework

时间复杂度和空间复杂度
![[flower carving hands-on] fun music visualization series small project (12) -- meter tube fast rhythm light](/img/99/6581b8a576e59a13aa4e977e3a1b70.jpg)
[flower carving hands-on] fun music visualization series small project (12) -- meter tube fast rhythm light

8 年产品经验,我总结了这些持续高效研发实践经验 · 研发篇

Learn about Pinia state getters actions plugins
随机推荐
基于ASP.NET的某高校学院档案管理系统
We were tossed all night by a Kong performance bug
Tupu 3D visual national style design | collision between technology and culture "cool" spark“
概率论与数理统计
LeetCode 69. x 的平方根
B+ tree index uses (7) matching column prefix, matching value range (19)
Flutter multi-channel packaging operation
Activity.onStop() 延迟10秒?精彩绝伦的排查历程
Oom caused by improper use of multithreading
8 年产品经验,我总结了这些持续高效研发实践经验 · 研发篇
1312_适用7z命令进行压缩与解压
天津市应急局与驻津央企签署协议深化应急联动机制建设
Learn about Pinia state getters actions plugins
Photoshop(CC2020)未完
Incorrect use of parentdatawidget when the exception was thrown, this was the stack:
Niuke brush sql---2
LeetCode 217. 存在重复元素
The parent component accesses the methods or parameters of the child component (the child component exposes the method defineexpose)
为什么要做“密评”?
Router. Push(), router. Reply(), router. Go()