# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
522398 | LucaDantas | Alternating Current (BOI18_alternating) | C++17 | 3058 ms | 332 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
constexpr int maxn = 20;
using pii = pair<int,int>;
int a[maxn], b[maxn];
bool mark[maxn][2];
int main() {
int n, m; scanf("%d %d", &n, &m);
for(int i = 0; i < m; i++)
scanf("%d %d", &a[i], &b[i]);
vector<int> ans(m);
for(int mask = 0; mask < (1 << m); mask++) {
memset(mark, 0, sizeof mark);
for(int i = 0; i < m; i++) {
int tp = (mask&(1<<i)) > 0;
for(int j = a[i]; j != b[i]; j = j%n +1)
mark[j][tp] = 1;
mark[b[i]][tp] = 1;
}
bool ok = 1;
for(int i = 1; i <= n; i++)
if(!mark[i][0] || !mark[i][1]) ok = 0;
if(ok) {
for(int i = 0; i < m; i++)
printf("%d", (mask&(1<<i)) > 0);
puts("");
return 0;
}
}
puts("impossible");
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |