Submission #441418

#TimeUsernameProblemLanguageResultExecution timeMemory
441418abc864197532Alternating Current (BOI18_alternating)C++17
0 / 100
27 ms1916 KiB
#include <bits/stdc++.h> using namespace std; #define lli long long int #define X first #define Y second #define pb push_back #define eb emplace_back #define mp make_pair #define pii pair<int, int> #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define test(args...) abc("[" + string(#args) + "]", args) void abc() {cerr << endl;} template <typename T, typename ...U> void abc(T a, U ...b) { cerr << a << ' ', abc(b...); } template <typename T> void printv(T l, T r) { while (l != r) cout << *l << " \n"[++l == r]; } const int mod = 1e9 + 7, N = 200000; int main () { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; vector <pii> a(m); int mx1 = 1, mx2 = 1; for (int i = 0; i < m; ++i) cin >> a[i].X >> a[i].Y; vector <int> ans(m, 0); vector <int> p(m); iota(all(p), 0); sort(all(p), [&](int i, int j) { return a[i].X < a[j].X; }); for (int i : p) { if (mx1 + 1 < a[i].X || mx2 + 1 < a[i].X) break; if (mx1 < mx2) { mx1 = max(mx1, a[i].Y); } else { mx2 = max(mx2, a[i].Y); ans[i] = 1; } } if (mx1 < n || mx2 < n) return cout << "impossible\n", 0; for (int i : ans) cout << i; cout << endl; }
#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...