Submission #63187

# Submission time Handle Problem Language Result Execution time Memory
63187 2018-08-01T04:38:07 Z 윤교준(#1834) Alternating Current (BOI18_alternating) C++11
19 / 100
70 ms 6868 KB
#include <bits/stdc++.h>
#define rf(x) (x)=0;while(*p<48)p++;while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);
#define pb push_back
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define befv(V) ((V)[(sz(V)-2)])
#define allv(V) ((V).begin()),((V).end())
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define clv(V) (V).clear()
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
void fuk() { puts("impossible"); exit(0); }

const int MAXN = 100005;
const int MAXM = 100005;

vector<int> G[MAXN];

int A[MAXM], B[MAXM];

int Ans[MAXM];
int N, M;

int main() {
	ios::sync_with_stdio(false);

	cin >> N >> M;
	for(int i = 1; i <= M; i++) cin >> A[i] >> B[i];

	for(int i = 1; i <= M; i++) G[A[i]].eb(i);

	int a = 0, b = 0;
	for(int i = 1; i <= N; i++) {
		for(int e : G[i]) {
			if(min(a, b) + 1 < i) fuk();
			if(a < b) {
				upmax(a, B[e]);
				Ans[e] = 0;
			} else {
				upmax(b, B[e]);
				Ans[e] = 1;
			}
		}
	}
	if(a < N || b < N) fuk();
	for(int i = 1; i <= M; i++) printf("%d", Ans[i]);
	puts("");

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2680 KB Output is correct
2 Correct 4 ms 2792 KB Output is correct
3 Incorrect 5 ms 2848 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2680 KB Output is correct
2 Correct 4 ms 2792 KB Output is correct
3 Incorrect 5 ms 2848 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2680 KB Output is correct
2 Correct 4 ms 2792 KB Output is correct
3 Incorrect 5 ms 2848 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 33 ms 4584 KB Output is correct
2 Correct 5 ms 4584 KB Output is correct
3 Correct 31 ms 4888 KB Output is correct
4 Correct 33 ms 5040 KB Output is correct
5 Correct 49 ms 6464 KB Output is correct
6 Correct 47 ms 6464 KB Output is correct
7 Correct 56 ms 6680 KB Output is correct
8 Correct 6 ms 6680 KB Output is correct
9 Correct 6 ms 6680 KB Output is correct
10 Correct 56 ms 6680 KB Output is correct
11 Correct 55 ms 6680 KB Output is correct
12 Correct 64 ms 6868 KB Output is correct
13 Correct 4 ms 6868 KB Output is correct
14 Correct 4 ms 6868 KB Output is correct
15 Correct 51 ms 6868 KB Output is correct
16 Correct 22 ms 6868 KB Output is correct
17 Correct 70 ms 6868 KB Output is correct
18 Correct 62 ms 6868 KB Output is correct
19 Correct 7 ms 6868 KB Output is correct
20 Correct 69 ms 6868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2680 KB Output is correct
2 Correct 4 ms 2792 KB Output is correct
3 Incorrect 5 ms 2848 KB 'impossible' claimed, but there is a solution
4 Halted 0 ms 0 KB -