Submission #251897

# Submission time Handle Problem Language Result Execution time Memory
251897 2020-07-23T03:21:11 Z jhnah917 Alternating Current (BOI18_alternating) C++14
19 / 100
48 ms 3192 KB
#include <bits/stdc++.h>
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define compress(v) sort(all(v)), v.erase(unique(all(v)), v.end())
using namespace std;

typedef long long ll;

struct Info{
    int s, e, x;
    Info() : Info(0, 0, 0) {}
    Info(int s, int e, int x) : s(s), e(e), x(x) {}
    bool operator < (const Info &t) const {
        if(s != t.s) return s < t.s;
        if(e != t.e) return e > t.e;
        return x < t.x;
    }
};

int n, m;
Info a[101010];
int ans[101010];

int main(){
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    cin >> n >> m;
    for(int i=1; i<=m; i++){ cin >> a[i].s >> a[i].e; a[i].x = i; }
    sort(a+1, a+m+1);
    int cnt0 = 0, cnt1 = 0;
    for(int i=1; i<=m; i++){
        int s = a[i].s, e = a[i].e, x = a[i].x;
        if(cnt0 < cnt1){
            if(cnt0 >= s-1) cnt0 = max(cnt0, e), ans[x] = 0;
        }else{
            if(cnt1 >= s-1) cnt1 = max(cnt1, e), ans[x] = 1;
        }
    }
    if(cnt0 < n || cnt1 < n){
        cout << "impossible"; return 0;
    }
    for(int i=1; i<=m; i++) cout << ans[i];
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1536 KB Output is correct
2 Correct 1 ms 1536 KB Output is correct
3 Incorrect 1 ms 1536 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1536 KB Output is correct
2 Correct 1 ms 1536 KB Output is correct
3 Incorrect 1 ms 1536 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1536 KB Output is correct
2 Correct 1 ms 1536 KB Output is correct
3 Incorrect 1 ms 1536 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 26 ms 2040 KB Output is correct
2 Correct 1 ms 1536 KB Output is correct
3 Correct 20 ms 2048 KB Output is correct
4 Correct 17 ms 2304 KB Output is correct
5 Correct 37 ms 3072 KB Output is correct
6 Correct 34 ms 3108 KB Output is correct
7 Correct 31 ms 3064 KB Output is correct
8 Correct 2 ms 1536 KB Output is correct
9 Correct 2 ms 1536 KB Output is correct
10 Correct 35 ms 3192 KB Output is correct
11 Correct 27 ms 2808 KB Output is correct
12 Correct 32 ms 2936 KB Output is correct
13 Correct 1 ms 1536 KB Output is correct
14 Correct 2 ms 1664 KB Output is correct
15 Correct 37 ms 3192 KB Output is correct
16 Correct 14 ms 2304 KB Output is correct
17 Correct 36 ms 3192 KB Output is correct
18 Correct 34 ms 2936 KB Output is correct
19 Correct 3 ms 1536 KB Output is correct
20 Correct 48 ms 3104 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1536 KB Output is correct
2 Correct 1 ms 1536 KB Output is correct
3 Incorrect 1 ms 1536 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -