Submission #1066645

#TimeUsernameProblemLanguageResultExecution timeMemory
106664512345678Alternating Current (BOI18_alternating)C++17
0 / 100
1 ms600 KiB
#include <bits/stdc++.h> using namespace std; const int nx=20; int n, m, a[nx], b[nx], dp[nx], vl; int main() { cin.tie(NULL)->sync_with_stdio(false); cin>>n>>m; for (int i=0; i<m; i++) cin>>a[i]>>b[i]; for (int msk=0; msk<(1<<m); msk++) { for (int i=0; i<n; i++) dp[i]=0; for (int i=0; i<m; i++) { if (msk&(1<<i)) vl=2; else vl=1; if (a[i]<=b[i]) { for (int j=a[i]; j<=b[i]; j++) dp[j]|=vl; } else { for (int j=1; j<=b[i]; j++) dp[j]|=vl; for (int j=a[i]; j<=n; j++) dp[j]|=vl; } } int f=0; for (int i=1; i<=n; i++) if (dp[i]!=3) f=1; if (!f) { for (int i=0; i<m;i ++) cout<<((msk&(1<<i))>0); return 0; } } cout<<"impossible"; }
#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...