# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
522400 | LucaDantas | Alternating Current (BOI18_alternating) | C++17 | 43 ms | 3088 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.
// subtask não circular
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
vector<pair<pii, int>> wires;
int main() {
int n, m; scanf("%d %d", &n, &m);
for(int i = 0, a, b; i < m; i++)
scanf("%d %d", &a, &b), wires.push_back({{a, b}, i});
sort(wires.begin(), wires.end());
vector<int> ans(m);
int a = 1, b = 1, cor = 0;
for(int i = 0; i < m; i++) {
if(a > b) swap(a, b), cor ^= 1;
if(wires[i].first.first > a) return puts("impossible"), 0;
a = max(a, wires[i].first.second + 1);
ans[wires[i].second] = cor;
}
if(min(a, b) < n+1) return puts("impossible"), 0;
for(int i = 0; i < m; i++)
printf("%d", ans[i]);
puts("");
}
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... |