Submission #863388

#TimeUsernameProblemLanguageResultExecution timeMemory
863388Trisanu_DasAlternating Current (BOI18_alternating)C++17
13 / 100
9 ms600 KiB
#include <bits/stdc++.h> using namespace std; int l[16], r[16]; bitset <16> ps[2]; int main() { int n, m; cin >> n >> m; for (int i = 0; i < m; i++) cin >> l[i] >> r[i], l[i]--, r[i]--; for (int mask = 0; mask < (1 << m); mask++) { ps[0] = ps[1] = 0; for (int i = 0; i < m; i++) { int L = l[i]; while (L != r[i]) ps[(mask >> i) & 1][L] = 1, L = (L + 1) % n; ps[(mask>>i)&1][r[i]] = 1; } bool flag = 1; for (int i = 0; i < n; i++) flag &= ps[0][i] & ps[1][i]; if (flag) { for (int i = 0; i < m; i++) cout << ((mask >> i) & 1); cout << '\n'; return 0; } } cout << "impossible\n"; }
#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...