# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
951716 | 2024-03-22T11:35:12 Z | mocha | Alternating Current (BOI18_alternating) | C++14 | 20 ms | 1628 KB |
#include <bits/stdc++.h> using namespace std; const int mx = 1e5+5; int n, m; struct Edge { int fr, to; int id; } e[mx]; bool ans[mx]; bool cmp( Edge a, Edge b ) { return a.fr == b.fr ? a.to > b.to : a.fr < b.fr; } int main() { cin.tie(0);ios::sync_with_stdio(0); cin >> n >> m; for (int i=0;i<m;i++) { cin >> e[i].fr >> e[i].to; e[i].id = i; } set<pair<int, int>> st; st.insert({1,0}); st.insert({1,1}); sort(e, e+m, cmp); bool fl = 1; int now = 0; for (int i=0;i<n;i++) { auto [num, ty] = *st.begin(); if (e[i].fr > num) { fl = 0; } else { ans[e[i].id] = ty; st.erase(st.begin()); st.insert({e[i].to+1, ty}); } } for (auto [i,j]:st) fl = (fl and (i>n)); if (fl) { for (int i=0;i<m;i++) { cout << ans[i]; } cout << "\n"; } else { cout << "impossible\n"; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | 'impossible' claimed, but there is a solution |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | 'impossible' claimed, but there is a solution |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | 'impossible' claimed, but there is a solution |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 1628 KB | Output is correct |
2 | Incorrect | 4 ms | 344 KB | 'impossible' claimed, but there is a solution |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | 'impossible' claimed, but there is a solution |
3 | Halted | 0 ms | 0 KB | - |