Submission #522398

# Submission time Handle Problem Language Result Execution time Memory
522398 2022-02-04T19:58:47 Z LucaDantas Alternating Current (BOI18_alternating) C++17
13 / 100
3000 ms 332 KB
#include <bits/stdc++.h>
using namespace std;

constexpr int maxn = 20;

using pii = pair<int,int>;

int a[maxn], b[maxn];
bool mark[maxn][2];

int main() {
	int n, m; scanf("%d %d", &n, &m);
	for(int i = 0; i < m; i++)
		scanf("%d %d", &a[i], &b[i]);

	vector<int> ans(m);

	for(int mask = 0; mask < (1 << m); mask++) {
		memset(mark, 0, sizeof mark);

		for(int i = 0; i < m; i++) {
			int tp = (mask&(1<<i)) > 0;
			for(int j = a[i]; j != b[i]; j = j%n +1)
				mark[j][tp] = 1;
			mark[b[i]][tp] = 1;
		}

		bool ok = 1;
		for(int i = 1; i <= n; i++)
			if(!mark[i][0] || !mark[i][1]) ok = 0;

		if(ok) {
			for(int i = 0; i < m; i++)
				printf("%d", (mask&(1<<i)) > 0);
			puts("");

			return 0;
		}
	}

	puts("impossible");
}

Compilation message

alternating.cpp: In function 'int main()':
alternating.cpp:12:17: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |  int n, m; scanf("%d %d", &n, &m);
      |            ~~~~~^~~~~~~~~~~~~~~~~
alternating.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |   scanf("%d %d", &a[i], &b[i]);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 288 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 288 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 296 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 1 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 0 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 0 ms 288 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 292 KB Output is correct
34 Correct 0 ms 204 KB Output is correct
35 Correct 11 ms 288 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 1 ms 204 KB Output is correct
38 Correct 8 ms 204 KB Output is correct
39 Correct 1 ms 288 KB Output is correct
40 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 288 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 288 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 296 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 1 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 0 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 0 ms 288 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 292 KB Output is correct
34 Correct 0 ms 204 KB Output is correct
35 Correct 11 ms 288 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 1 ms 204 KB Output is correct
38 Correct 8 ms 204 KB Output is correct
39 Correct 1 ms 288 KB Output is correct
40 Correct 0 ms 204 KB Output is correct
41 Execution timed out 3058 ms 204 KB Time limit exceeded
42 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 288 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 288 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 296 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 1 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 0 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 0 ms 288 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 292 KB Output is correct
34 Correct 0 ms 204 KB Output is correct
35 Correct 11 ms 288 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 1 ms 204 KB Output is correct
38 Correct 8 ms 204 KB Output is correct
39 Correct 1 ms 288 KB Output is correct
40 Correct 0 ms 204 KB Output is correct
41 Execution timed out 3058 ms 204 KB Time limit exceeded
42 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 288 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 288 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 296 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 1 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 0 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 0 ms 288 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 292 KB Output is correct
34 Correct 0 ms 204 KB Output is correct
35 Correct 11 ms 288 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 1 ms 204 KB Output is correct
38 Correct 8 ms 204 KB Output is correct
39 Correct 1 ms 288 KB Output is correct
40 Correct 0 ms 204 KB Output is correct
41 Execution timed out 3058 ms 204 KB Time limit exceeded
42 Halted 0 ms 0 KB -