# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1114955 | 2024-11-19T20:38:58 Z | lucascgar | Alternating Current (BOI18_alternating) | C++17 | 92 ms | 9660 KB |
#include <bits/stdc++.h> using namespace std; /* */ typedef pair<int, int> pii; typedef pair<long long, long long> pll; typedef pair<long double, long double> pdd; const int MAXN = 1e5+10; vector<int> w[MAXN]; bool ty[MAXN]; signed main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); // cout << fixed << setprecision(7); int n, m; cin >> n >> m; int a, b; for (int i=0;i<m;i++){ cin >> a >> b; if(b<a) return 0; w[a].push_back(i); w[b].push_back(i); } set<int> cr; int ps=-1, ng=-1; bool valid = 1; for (int i=1;i<=n;i++){ vector<int> rm; while (!w[i].empty()){ int u = w[i].back(); w[i].pop_back(); if (!cr.count(u) && ps != u && ng != u){ cr.insert(u); } else{ rm.push_back(u); } } if (cr.size() < (int)(ps==-1)+(ng==-1)){ valid = 0; break; } if (ps==-1){ ps = *cr.begin(); cr.erase(cr.begin()); ty[ps]=0; } if (ng==-1){ ng = *cr.begin(); cr.erase(cr.begin()); ty[ng]=1; } for (auto &u:rm){ cr.erase(u); if (ps==u) ps=-1; if (ng==u) ng=-1; } } if (!valid){ cout << "impossible\n"; return 0; } for (int i=0;i<m;i++) cout << (int)ty[i]; cout << '\n'; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2640 KB | Output is correct |
2 | Correct | 1 ms | 2640 KB | Output is correct |
3 | Incorrect | 1 ms | 2640 KB | Unexpected end of file - token expected |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2640 KB | Output is correct |
2 | Correct | 1 ms | 2640 KB | Output is correct |
3 | Incorrect | 1 ms | 2640 KB | Unexpected end of file - token expected |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2640 KB | Output is correct |
2 | Correct | 1 ms | 2640 KB | Output is correct |
3 | Incorrect | 1 ms | 2640 KB | Unexpected end of file - token expected |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 50 ms | 9660 KB | Output is correct |
2 | Correct | 2 ms | 2640 KB | Output is correct |
3 | Correct | 11 ms | 6212 KB | Output is correct |
4 | Correct | 27 ms | 8784 KB | Output is correct |
5 | Correct | 35 ms | 6984 KB | Output is correct |
6 | Correct | 30 ms | 6252 KB | Output is correct |
7 | Correct | 32 ms | 6984 KB | Output is correct |
8 | Correct | 3 ms | 2896 KB | Output is correct |
9 | Correct | 2 ms | 2640 KB | Output is correct |
10 | Correct | 31 ms | 6992 KB | Output is correct |
11 | Correct | 34 ms | 6472 KB | Output is correct |
12 | Correct | 33 ms | 6988 KB | Output is correct |
13 | Correct | 2 ms | 2640 KB | Output is correct |
14 | Correct | 2 ms | 2640 KB | Output is correct |
15 | Correct | 32 ms | 5952 KB | Output is correct |
16 | Correct | 24 ms | 8780 KB | Output is correct |
17 | Correct | 92 ms | 9032 KB | Output is correct |
18 | Correct | 90 ms | 7628 KB | Output is correct |
19 | Correct | 3 ms | 3320 KB | Output is correct |
20 | Correct | 24 ms | 5456 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2640 KB | Output is correct |
2 | Correct | 1 ms | 2640 KB | Output is correct |
3 | Incorrect | 1 ms | 2640 KB | Unexpected end of file - token expected |
4 | Halted | 0 ms | 0 KB | - |