Submission #532705

#TimeUsernameProblemLanguageResultExecution timeMemory
532705fatemetmhrAlternating Current (BOI18_alternating)C++17
13 / 100
12 ms712 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define pb push_back mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int maxn5 = 5e3 + 10; int a[maxn5], b[maxn5]; bool av[2][maxn5]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, m; cin >> n >> m; for(int i = 0; i < m; i++){ cin >> a[i] >> b[i]; a[i]--; b[i]--; } for(int mask = 1; mask < (1 << m) - 1; mask++){ memset(av, false, sizeof av); for(int i = 0; i < m; i++){ int x = a[i]; while(true){ av[(mask >> i)&1][x] = true; if(x == b[i]) break; x++; if(x == n) x = 0; } } bool re = true; for(int i = 0; i < n; i++) if(!av[0][i] || !av[1][i]) re = false; if(re){ for(int i = 0; i < m; i++) cout << ((mask >> i)&1); return cout << endl, 0; } } cout << "impossible" << endl; }
#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...