Submission #441420

# Submission time Handle Problem Language Result Execution time Memory
441420 2021-07-05T07:16:39 Z abc864197532 Alternating Current (BOI18_alternating) C++17
19 / 100
37 ms 3024 KB
#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 = 0, mx2 = 0;
    for (int i = 0; i < m; ++i) cin >> a[i].X >> a[i].Y, --a[i].X;
    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 < a[i].X || mx2 < 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 time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 26 ms 1872 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 11 ms 1100 KB Output is correct
4 Correct 16 ms 1108 KB Output is correct
5 Correct 35 ms 2936 KB Output is correct
6 Correct 32 ms 3024 KB Output is correct
7 Correct 33 ms 2752 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 37 ms 3020 KB Output is correct
11 Correct 27 ms 2340 KB Output is correct
12 Correct 32 ms 2760 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 0 ms 312 KB Output is correct
15 Correct 37 ms 3012 KB Output is correct
16 Correct 11 ms 1680 KB Output is correct
17 Correct 37 ms 3020 KB Output is correct
18 Correct 34 ms 2876 KB Output is correct
19 Correct 2 ms 460 KB Output is correct
20 Correct 36 ms 3012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -