Submission #171296

#TimeUsernameProblemLanguageResultExecution timeMemory
171296parsa_mobedAlternating Current (BOI18_alternating)C++14
13 / 100
16 ms380 KiB
#include <bits/stdc++.h> using namespace std; const int N = 16; int l[N], r[N]; bitset <N> 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"; 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...