Submission #473473

# Submission time Handle Problem Language Result Execution time Memory
473473 2021-09-15T14:54:09 Z Hamed5001 Alternating Current (BOI18_alternating) C++14
13 / 100
3000 ms 2124 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int N, M;
vector<pair<int, int>> wires;

bool can(int msk) {
	vector<vector<bool>> cov(2, vector<bool>(N, 0));
	for (int i = M-1, j = 0; i >= 0; i--, j++) {
		bool which = msk & (1 << i);
		for (int k = wires[j].first; k != wires[j].second; (k+=1)%=N) {
			cov[which][k] = 1;
		}
		cov[which][wires[j].second] = 1;
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 2; j++) {
			if (!cov[j][i]) return false;
		}
	}

	return true;
}

void solve() {
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		wires.push_back({--a, --b});
	}
	for (int msk = 0; msk < (1 << M); msk++) {
		if (can(msk)) {
			for (int i = M-1; i >= 0; i--) {
				cout << (1 & (msk >> i));
			}
			return;
		}
	}

	cout << "impossible";
}

int main() {
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	solve();
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 2 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 4 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 308 KB Output is correct
27 Correct 2 ms 204 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 0 ms 312 KB Output is correct
31 Correct 1 ms 208 KB Output is correct
32 Correct 1 ms 208 KB Output is correct
33 Correct 1 ms 208 KB Output is correct
34 Correct 1 ms 316 KB Output is correct
35 Correct 18 ms 324 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 1 ms 208 KB Output is correct
38 Correct 16 ms 316 KB Output is correct
39 Correct 1 ms 208 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 2 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 4 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 308 KB Output is correct
27 Correct 2 ms 204 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 0 ms 312 KB Output is correct
31 Correct 1 ms 208 KB Output is correct
32 Correct 1 ms 208 KB Output is correct
33 Correct 1 ms 208 KB Output is correct
34 Correct 1 ms 316 KB Output is correct
35 Correct 18 ms 324 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 1 ms 208 KB Output is correct
38 Correct 16 ms 316 KB Output is correct
39 Correct 1 ms 208 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 204 KB Output is correct
42 Correct 2 ms 204 KB Output is correct
43 Incorrect 0 ms 204 KB 'impossible' claimed, but there is a solution
44 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 2 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 4 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 308 KB Output is correct
27 Correct 2 ms 204 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 0 ms 312 KB Output is correct
31 Correct 1 ms 208 KB Output is correct
32 Correct 1 ms 208 KB Output is correct
33 Correct 1 ms 208 KB Output is correct
34 Correct 1 ms 316 KB Output is correct
35 Correct 18 ms 324 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 1 ms 208 KB Output is correct
38 Correct 16 ms 316 KB Output is correct
39 Correct 1 ms 208 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 204 KB Output is correct
42 Correct 2 ms 204 KB Output is correct
43 Incorrect 0 ms 204 KB 'impossible' claimed, but there is a solution
44 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3030 ms 2124 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 2 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 4 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 308 KB Output is correct
27 Correct 2 ms 204 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 0 ms 312 KB Output is correct
31 Correct 1 ms 208 KB Output is correct
32 Correct 1 ms 208 KB Output is correct
33 Correct 1 ms 208 KB Output is correct
34 Correct 1 ms 316 KB Output is correct
35 Correct 18 ms 324 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 1 ms 208 KB Output is correct
38 Correct 16 ms 316 KB Output is correct
39 Correct 1 ms 208 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 204 KB Output is correct
42 Correct 2 ms 204 KB Output is correct
43 Incorrect 0 ms 204 KB 'impossible' claimed, but there is a solution
44 Halted 0 ms 0 KB -