Submission #63053

#TimeUsernameProblemLanguageResultExecution timeMemory
63053zetapiAlternating Current (BOI18_alternating)C++14
0 / 100
3072 ms3968 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define int long long #define itr ::iterator typedef pair<int,int> pii; const int MAX=1e5; int N,M,X[MAX],Y[MAX],mark[MAX][2]; bool ok(int mask) { for(int A=0;A<N;A++) { mark[A][0]=0; mark[A][1]=0; } for(int A=0;A<M;A++) { if(X[A]>Y[A]) { for(int B=Y[A];B<N;B++) mark[B][((mask&(1<<A))!=0)]=1; for(int B=0;B<X[A];B++) mark[B][((mask&(1<<A))!=0)]=1; } else { for(int B=X[A];B<=Y[A];B++) mark[B][((mask&(1<<A))!=0)]=1; } } for(int A=0;A<N;A++) if(mark[A][0]+mark[A][1]!=2) return false; return true; } signed main() { ios_base::sync_with_stdio(false); cin>>N>>M; for(int A=0;A<M;A++) { cin>>X[A]>>Y[A]; X[A]--; Y[A]--; } for(int A=0;A<(1<<M);A++) { if(ok(A)) { for(int C=0;C<M;C++) cout<<(((A&(1<<C))!=0)?1:0); return 0; } } cout<<"impossible"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...