Codeforces Round #656 (Div. 3)
Posted hahaee
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Codeforces Round #656 (Div. 3)相关的知识,希望对你有一定的参考价值。
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=2e5+3; typedef long long ll; const ll inf=1e18; ll a[N],b[N]; int main() { int t;cin>>t; while(t--) { int x,y,z; cin>>x>>y>>z; if(x==y&&x==z) { printf("YES "); printf("%d %d %d ",x,x,x); } else if(x==y) { if(z<x) {printf("YES "); printf("%d %d %d ",x,z,z); } else printf("NO "); } else if(y==z) { if(x<z) {printf("YES "); printf("%d %d %d ",z,x,x); } else printf("NO "); } else if(x==z) { if(y<x) {printf("YES "); printf("%d %d %d ",x,y,y); } else printf("NO "); } else printf("NO "); } }
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=2e5+3; typedef long long ll; const ll inf=1e18; ll a[N],b[N]; int main() { int t;cin>>t; while(t--) { int n,r=0;cin>>n; for(int i=1;i<=n;i++) { cin>>a[i]; } int i=1,ans=1; if(a[i+1]>=a[i]) { while(a[i+1]>=a[i]&&i>1) { i++; ans++; } while(a[i+1]<=a[i]&&i>1) { i++; ans++; } r=max(ans,r); ans=1; } else if(a[i+1]<=a[i]) { while(a[i+1]<=a[i]&&i>1) { i++; ans++; } } r=max(ans,r); i=n,ans=1; if(a[i-1]>=a[i]) { while(a[i-1]>=a[i]&&i>1) { i--; ans++; } while(a[i-1]<=a[i]&&i>1) { i--; ans++; } r=max(ans,r); ans=1; } else if(a[i-1]<=a[i]) { while(a[i-1]<=a[i]&&i>1) { i--; ans++; } } r=max(ans,r); printf("%d ",n-r); } }
Restore the Permutation by Merger
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=2e5+3; typedef long long ll; const ll inf=1e18; ll a[N],b[N]; int main() { int t;cin>>t; while(t--) { int n;cin>>n; for(int i=1;i<=2*n;i++) { cin>>a[i]; b[a[i]]++; if(b[a[i]]%2==0) printf("%d ",a[i]); } printf(" "); } }
以上是关于Codeforces Round #656 (Div. 3)的主要内容,如果未能解决你的问题,请参考以下文章
Codeforces Round #656 (Div. 3)
Codeforces Round #656 (Div. 3) A. Three Pairwise Maximums(思维/构造)
Codeforces Round #656 (Div. 3) E. Directing Edges
Codeforces Round #656 (Div. 3) E. Directing Edges
Codeforces Round #656 (Div. 3) E. Directing Edges
Codeforces Round #656 (Div. 3)E. Directing Edges(拓扑排序+构造dag图)