标签:pre ios seq min max main return class force
贪心
#include <iostream> #include<algorithm> #include<string.h> #include<set> using namespace std; const int maxn=100010; int ans[maxn]; int a[4]; void solve() { int a,b,c,d; cin>>a>>b>>c>>d; if(a>b) { if(a==b+1&&!c&&!d) { cout<<"YES"<<endl; for(int i=0;i<b;i++) cout<<"0 1 "; cout<<0<<endl; return ; } else { cout<<"NO"<<endl; return ; } } if(d>c) { if(d==c+1&&!a&&!b) { cout<<"YES"<<endl; for(int i=0;i<c;i++) cout<<"3 2 "; cout<<3<<endl; return ; } else { cout<<"NO"<<endl; return ; } } b-=a; c-=d; if(abs(b-c)>1) { cout<<"NO"<<endl; return ; } else { cout<<"YES"<<endl; if(b==c+1) cout<<"1 "; for(int i=0;i<a;i++) cout<<"0 1 "; for(int i=0;i<min(b,c);i++) cout<<"2 1 "; for(int i=0;i<d;i++) cout<<"2 3 "; if(1+b==c) cout<<"2 "; } } int main() { solve(); return 0; }
CodeForces 1265 D. Beautiful Sequence
标签:pre ios seq min max main return class force
原文地址:https://www.cnblogs.com/AAAzhuo/p/12002667.html