Submission #63192

# Submission time Handle Problem Language Result Execution time Memory
63192 2018-08-01T05:15:54 Z 윤교준(#1834) Alternating Current (BOI18_alternating) C++11
32 / 100
2438 ms 7240 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];

	if(M <= 15) {
		bool chk[2][MAXN];
		for(int key = 0; key < (1<<M); key++) {
			fill(chk[0], chk[0]+N+1, false);
			fill(chk[1], chk[1]+N+1, false);

			for(int i = 1; i <= M; i++) {
				int type = !!(key & (1<<(i-1)));
				if(A[i] <= B[i]) {
					for(int k = A[i]; k <= B[i]; k++)
						chk[type][k] = true;
				} else {
					for(int k = A[i]; k <= N; k++)
						chk[type][k] = true;
					for(int k = 1; k <= B[i]; k++)
						chk[type][k] = true;
				}
			}

			bool flag = false;
			for(int i = 1; i <= N; i++)
				if(!chk[0][i] || !chk[1][i]) flag = true;
			if(flag) continue;

			for(int i = 0; i < M; i++)
				printf("%d", !!(key & (1<<i)));
			puts("");
			return 0;
		}
		fuk();
	}

	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 5 ms 2920 KB Output is correct
3 Correct 5 ms 2920 KB Output is correct
4 Correct 7 ms 2920 KB Output is correct
5 Correct 5 ms 2920 KB Output is correct
6 Correct 6 ms 2920 KB Output is correct
7 Correct 6 ms 2932 KB Output is correct
8 Correct 4 ms 3012 KB Output is correct
9 Correct 6 ms 3012 KB Output is correct
10 Correct 3 ms 3012 KB Output is correct
11 Correct 6 ms 3012 KB Output is correct
12 Correct 5 ms 3012 KB Output is correct
13 Correct 5 ms 3012 KB Output is correct
14 Correct 5 ms 3076 KB Output is correct
15 Correct 6 ms 3076 KB Output is correct
16 Correct 5 ms 3076 KB Output is correct
17 Correct 6 ms 3104 KB Output is correct
18 Correct 6 ms 3104 KB Output is correct
19 Correct 4 ms 3104 KB Output is correct
20 Correct 5 ms 3104 KB Output is correct
21 Correct 4 ms 3104 KB Output is correct
22 Correct 5 ms 3104 KB Output is correct
23 Correct 3 ms 3104 KB Output is correct
24 Correct 4 ms 3104 KB Output is correct
25 Correct 4 ms 3104 KB Output is correct
26 Correct 5 ms 3104 KB Output is correct
27 Correct 5 ms 3104 KB Output is correct
28 Correct 5 ms 3104 KB Output is correct
29 Correct 5 ms 3104 KB Output is correct
30 Correct 5 ms 3104 KB Output is correct
31 Correct 7 ms 3104 KB Output is correct
32 Correct 5 ms 3104 KB Output is correct
33 Correct 5 ms 3104 KB Output is correct
34 Correct 5 ms 3104 KB Output is correct
35 Correct 12 ms 3104 KB Output is correct
36 Correct 5 ms 3104 KB Output is correct
37 Correct 5 ms 3184 KB Output is correct
38 Correct 10 ms 3184 KB Output is correct
39 Correct 5 ms 3184 KB Output is correct
40 Correct 5 ms 3184 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2680 KB Output is correct
2 Correct 5 ms 2920 KB Output is correct
3 Correct 5 ms 2920 KB Output is correct
4 Correct 7 ms 2920 KB Output is correct
5 Correct 5 ms 2920 KB Output is correct
6 Correct 6 ms 2920 KB Output is correct
7 Correct 6 ms 2932 KB Output is correct
8 Correct 4 ms 3012 KB Output is correct
9 Correct 6 ms 3012 KB Output is correct
10 Correct 3 ms 3012 KB Output is correct
11 Correct 6 ms 3012 KB Output is correct
12 Correct 5 ms 3012 KB Output is correct
13 Correct 5 ms 3012 KB Output is correct
14 Correct 5 ms 3076 KB Output is correct
15 Correct 6 ms 3076 KB Output is correct
16 Correct 5 ms 3076 KB Output is correct
17 Correct 6 ms 3104 KB Output is correct
18 Correct 6 ms 3104 KB Output is correct
19 Correct 4 ms 3104 KB Output is correct
20 Correct 5 ms 3104 KB Output is correct
21 Correct 4 ms 3104 KB Output is correct
22 Correct 5 ms 3104 KB Output is correct
23 Correct 3 ms 3104 KB Output is correct
24 Correct 4 ms 3104 KB Output is correct
25 Correct 4 ms 3104 KB Output is correct
26 Correct 5 ms 3104 KB Output is correct
27 Correct 5 ms 3104 KB Output is correct
28 Correct 5 ms 3104 KB Output is correct
29 Correct 5 ms 3104 KB Output is correct
30 Correct 5 ms 3104 KB Output is correct
31 Correct 7 ms 3104 KB Output is correct
32 Correct 5 ms 3104 KB Output is correct
33 Correct 5 ms 3104 KB Output is correct
34 Correct 5 ms 3104 KB Output is correct
35 Correct 12 ms 3104 KB Output is correct
36 Correct 5 ms 3104 KB Output is correct
37 Correct 5 ms 3184 KB Output is correct
38 Correct 10 ms 3184 KB Output is correct
39 Correct 5 ms 3184 KB Output is correct
40 Correct 5 ms 3184 KB Output is correct
41 Correct 5 ms 3184 KB Output is correct
42 Correct 5 ms 3184 KB Output is correct
43 Incorrect 7 ms 3184 KB 'impossible' claimed, but there is a solution
44 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2680 KB Output is correct
2 Correct 5 ms 2920 KB Output is correct
3 Correct 5 ms 2920 KB Output is correct
4 Correct 7 ms 2920 KB Output is correct
5 Correct 5 ms 2920 KB Output is correct
6 Correct 6 ms 2920 KB Output is correct
7 Correct 6 ms 2932 KB Output is correct
8 Correct 4 ms 3012 KB Output is correct
9 Correct 6 ms 3012 KB Output is correct
10 Correct 3 ms 3012 KB Output is correct
11 Correct 6 ms 3012 KB Output is correct
12 Correct 5 ms 3012 KB Output is correct
13 Correct 5 ms 3012 KB Output is correct
14 Correct 5 ms 3076 KB Output is correct
15 Correct 6 ms 3076 KB Output is correct
16 Correct 5 ms 3076 KB Output is correct
17 Correct 6 ms 3104 KB Output is correct
18 Correct 6 ms 3104 KB Output is correct
19 Correct 4 ms 3104 KB Output is correct
20 Correct 5 ms 3104 KB Output is correct
21 Correct 4 ms 3104 KB Output is correct
22 Correct 5 ms 3104 KB Output is correct
23 Correct 3 ms 3104 KB Output is correct
24 Correct 4 ms 3104 KB Output is correct
25 Correct 4 ms 3104 KB Output is correct
26 Correct 5 ms 3104 KB Output is correct
27 Correct 5 ms 3104 KB Output is correct
28 Correct 5 ms 3104 KB Output is correct
29 Correct 5 ms 3104 KB Output is correct
30 Correct 5 ms 3104 KB Output is correct
31 Correct 7 ms 3104 KB Output is correct
32 Correct 5 ms 3104 KB Output is correct
33 Correct 5 ms 3104 KB Output is correct
34 Correct 5 ms 3104 KB Output is correct
35 Correct 12 ms 3104 KB Output is correct
36 Correct 5 ms 3104 KB Output is correct
37 Correct 5 ms 3184 KB Output is correct
38 Correct 10 ms 3184 KB Output is correct
39 Correct 5 ms 3184 KB Output is correct
40 Correct 5 ms 3184 KB Output is correct
41 Correct 5 ms 3184 KB Output is correct
42 Correct 5 ms 3184 KB Output is correct
43 Incorrect 7 ms 3184 KB 'impossible' claimed, but there is a solution
44 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 33 ms 4920 KB Output is correct
2 Correct 6 ms 4920 KB Output is correct
3 Correct 25 ms 5096 KB Output is correct
4 Correct 25 ms 5272 KB Output is correct
5 Correct 70 ms 6564 KB Output is correct
6 Correct 59 ms 6564 KB Output is correct
7 Correct 81 ms 6836 KB Output is correct
8 Correct 8 ms 6836 KB Output is correct
9 Correct 5 ms 6836 KB Output is correct
10 Correct 76 ms 6836 KB Output is correct
11 Correct 77 ms 6836 KB Output is correct
12 Correct 81 ms 7240 KB Output is correct
13 Correct 2438 ms 7240 KB Output is correct
14 Correct 5 ms 7240 KB Output is correct
15 Correct 69 ms 7240 KB Output is correct
16 Correct 20 ms 7240 KB Output is correct
17 Correct 68 ms 7240 KB Output is correct
18 Correct 43 ms 7240 KB Output is correct
19 Correct 7 ms 7240 KB Output is correct
20 Correct 42 ms 7240 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2680 KB Output is correct
2 Correct 5 ms 2920 KB Output is correct
3 Correct 5 ms 2920 KB Output is correct
4 Correct 7 ms 2920 KB Output is correct
5 Correct 5 ms 2920 KB Output is correct
6 Correct 6 ms 2920 KB Output is correct
7 Correct 6 ms 2932 KB Output is correct
8 Correct 4 ms 3012 KB Output is correct
9 Correct 6 ms 3012 KB Output is correct
10 Correct 3 ms 3012 KB Output is correct
11 Correct 6 ms 3012 KB Output is correct
12 Correct 5 ms 3012 KB Output is correct
13 Correct 5 ms 3012 KB Output is correct
14 Correct 5 ms 3076 KB Output is correct
15 Correct 6 ms 3076 KB Output is correct
16 Correct 5 ms 3076 KB Output is correct
17 Correct 6 ms 3104 KB Output is correct
18 Correct 6 ms 3104 KB Output is correct
19 Correct 4 ms 3104 KB Output is correct
20 Correct 5 ms 3104 KB Output is correct
21 Correct 4 ms 3104 KB Output is correct
22 Correct 5 ms 3104 KB Output is correct
23 Correct 3 ms 3104 KB Output is correct
24 Correct 4 ms 3104 KB Output is correct
25 Correct 4 ms 3104 KB Output is correct
26 Correct 5 ms 3104 KB Output is correct
27 Correct 5 ms 3104 KB Output is correct
28 Correct 5 ms 3104 KB Output is correct
29 Correct 5 ms 3104 KB Output is correct
30 Correct 5 ms 3104 KB Output is correct
31 Correct 7 ms 3104 KB Output is correct
32 Correct 5 ms 3104 KB Output is correct
33 Correct 5 ms 3104 KB Output is correct
34 Correct 5 ms 3104 KB Output is correct
35 Correct 12 ms 3104 KB Output is correct
36 Correct 5 ms 3104 KB Output is correct
37 Correct 5 ms 3184 KB Output is correct
38 Correct 10 ms 3184 KB Output is correct
39 Correct 5 ms 3184 KB Output is correct
40 Correct 5 ms 3184 KB Output is correct
41 Correct 5 ms 3184 KB Output is correct
42 Correct 5 ms 3184 KB Output is correct
43 Incorrect 7 ms 3184 KB 'impossible' claimed, but there is a solution
44 Halted 0 ms 0 KB -