Submission #536629

# Submission time Handle Problem Language Result Execution time Memory
536629 2022-03-13T15:35:15 Z OttoTheDino Alternating Current (BOI18_alternating) C++17
19 / 100
75 ms 10708 KB
#include <bits/stdc++.h>
using namespace std;

#define rep(i,s,e)                  for (int i = s; i <= e; ++i)
#define rrep(i,s,e)                 for (int i = s; i >= e; --i)
#define pb                          push_back
#define pf                          push_front
#define fi                          first
#define se                          second
#define all(a)                      a.begin(), a.end()
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n, m, l = 0, r = 0; cin >>n >> m;
    vector<ii> v[n+1];
    set<ii> st;
    rep (i,1,m) {
        int a, b; cin >> a >> b;
        v[a].pb({b,i});
    }
    bool suc = 1, ans[m+1] = {};
    rep (i,1,n) {
        for (ii bi : v[i]) st.insert(bi);
        if (l<i) {
            if (st.size() && (*st.rbegin()).fi>=i) {
                l = (*st.rbegin()).fi;
                st.erase(--st.end());
            }
            else {
                suc = 0;
                break;
            }
        }
        if (r<i) {
            if (st.size() && (*st.rbegin()).fi>=i) {
                ans[(*st.rbegin()).se] = 1;
                r = (*st.rbegin()).fi;
                st.erase(--st.end());
            }
            else {
                suc = 0;
                break;
            }
        }
    }
    if (!suc) cout << "impossible\n";
    else {
        rep (i,1,m) cout << ans[i];
        cout << "\n";
    }
    return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 37 ms 9300 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 11 ms 4820 KB Output is correct
4 Correct 21 ms 7240 KB Output is correct
5 Correct 32 ms 6136 KB Output is correct
6 Correct 31 ms 6988 KB Output is correct
7 Correct 33 ms 6348 KB Output is correct
8 Correct 3 ms 2768 KB Output is correct
9 Correct 2 ms 2516 KB Output is correct
10 Correct 34 ms 6252 KB Output is correct
11 Correct 24 ms 5648 KB Output is correct
12 Correct 28 ms 6608 KB Output is correct
13 Correct 2 ms 2632 KB Output is correct
14 Correct 2 ms 2648 KB Output is correct
15 Correct 53 ms 9420 KB Output is correct
16 Correct 21 ms 7140 KB Output is correct
17 Correct 75 ms 10708 KB Output is correct
18 Correct 56 ms 7372 KB Output is correct
19 Correct 3 ms 2900 KB Output is correct
20 Correct 27 ms 4308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -