Submission #128502

# Submission time Handle Problem Language Result Execution time Memory
128502 2019-07-11T04:23:00 Z 임유진(#3161) Rope (JOI17_rope) C++14
80 / 100
298 ms 138368 KB
#include <stdio.h>
#include <algorithm>

using namespace std;

#define MAXN 1000005
#define MAXM 5005

int C[MAXN];
int A[MAXM], cha[MAXM][MAXM][2], ans[MAXM][MAXM];

int main() {
	int N, M;

	scanf("%d%d", &N, &M);
	for(int i = 0; i < N; i++) scanf("%d", C + i);

	for(int i = 0; i < N; i++) A[C[i]]++;
	for(int i = 0; i < N - 1; i++) {
		cha[C[i]][C[i + 1]][i % 2]++;
		cha[C[i + 1]][C[i]][i % 2]++;
	}

	for(int i = 1; i <= M; i++) for(int j = 1; j <= M; j++) if(i != j)
		ans[i][j] = N - A[i] - A[j] + min(cha[i][j][0], cha[i][j][1]);

	for(int i = 1; i <= M; i++) {
		int mn = N - A[i];
		for(int j = 1; j <= M; j++) if(i != j) mn = min(mn, ans[i][j]);
		printf("%d\n", mn);
	}

	return 0;
}

Compilation message

rope.cpp: In function 'int main()':
rope.cpp:15:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &N, &M);
  ~~~~~^~~~~~~~~~~~~~~~
rope.cpp:16:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i = 0; i < N; i++) scanf("%d", C + i);
                             ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 380 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 380 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 380 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 380 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 380 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 380 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 13 ms 1016 KB Output is correct
28 Correct 12 ms 1020 KB Output is correct
29 Correct 12 ms 1020 KB Output is correct
30 Correct 12 ms 1016 KB Output is correct
31 Correct 13 ms 1016 KB Output is correct
32 Correct 12 ms 888 KB Output is correct
33 Correct 12 ms 1016 KB Output is correct
34 Correct 12 ms 892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 380 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 380 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 380 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 13 ms 1016 KB Output is correct
28 Correct 12 ms 1020 KB Output is correct
29 Correct 12 ms 1020 KB Output is correct
30 Correct 12 ms 1016 KB Output is correct
31 Correct 13 ms 1016 KB Output is correct
32 Correct 12 ms 888 KB Output is correct
33 Correct 12 ms 1016 KB Output is correct
34 Correct 12 ms 892 KB Output is correct
35 Correct 20 ms 8056 KB Output is correct
36 Correct 20 ms 8056 KB Output is correct
37 Correct 20 ms 7672 KB Output is correct
38 Correct 20 ms 7800 KB Output is correct
39 Correct 20 ms 8056 KB Output is correct
40 Correct 20 ms 8080 KB Output is correct
41 Correct 20 ms 8056 KB Output is correct
42 Correct 18 ms 6136 KB Output is correct
43 Correct 17 ms 4552 KB Output is correct
44 Correct 20 ms 8024 KB Output is correct
45 Correct 20 ms 7928 KB Output is correct
46 Correct 18 ms 6136 KB Output is correct
47 Correct 17 ms 4472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 380 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 380 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 380 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 13 ms 1016 KB Output is correct
28 Correct 12 ms 1020 KB Output is correct
29 Correct 12 ms 1020 KB Output is correct
30 Correct 12 ms 1016 KB Output is correct
31 Correct 13 ms 1016 KB Output is correct
32 Correct 12 ms 888 KB Output is correct
33 Correct 12 ms 1016 KB Output is correct
34 Correct 12 ms 892 KB Output is correct
35 Correct 20 ms 8056 KB Output is correct
36 Correct 20 ms 8056 KB Output is correct
37 Correct 20 ms 7672 KB Output is correct
38 Correct 20 ms 7800 KB Output is correct
39 Correct 20 ms 8056 KB Output is correct
40 Correct 20 ms 8080 KB Output is correct
41 Correct 20 ms 8056 KB Output is correct
42 Correct 18 ms 6136 KB Output is correct
43 Correct 17 ms 4552 KB Output is correct
44 Correct 20 ms 8024 KB Output is correct
45 Correct 20 ms 7928 KB Output is correct
46 Correct 18 ms 6136 KB Output is correct
47 Correct 17 ms 4472 KB Output is correct
48 Correct 297 ms 138368 KB Output is correct
49 Correct 295 ms 138360 KB Output is correct
50 Correct 298 ms 138232 KB Output is correct
51 Correct 190 ms 47096 KB Output is correct
52 Correct 155 ms 27888 KB Output is correct
53 Correct 272 ms 138180 KB Output is correct
54 Correct 265 ms 137692 KB Output is correct
55 Correct 264 ms 137464 KB Output is correct
56 Correct 261 ms 136440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 380 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 380 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 380 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 13 ms 1016 KB Output is correct
28 Correct 12 ms 1020 KB Output is correct
29 Correct 12 ms 1020 KB Output is correct
30 Correct 12 ms 1016 KB Output is correct
31 Correct 13 ms 1016 KB Output is correct
32 Correct 12 ms 888 KB Output is correct
33 Correct 12 ms 1016 KB Output is correct
34 Correct 12 ms 892 KB Output is correct
35 Correct 20 ms 8056 KB Output is correct
36 Correct 20 ms 8056 KB Output is correct
37 Correct 20 ms 7672 KB Output is correct
38 Correct 20 ms 7800 KB Output is correct
39 Correct 20 ms 8056 KB Output is correct
40 Correct 20 ms 8080 KB Output is correct
41 Correct 20 ms 8056 KB Output is correct
42 Correct 18 ms 6136 KB Output is correct
43 Correct 17 ms 4552 KB Output is correct
44 Correct 20 ms 8024 KB Output is correct
45 Correct 20 ms 7928 KB Output is correct
46 Correct 18 ms 6136 KB Output is correct
47 Correct 17 ms 4472 KB Output is correct
48 Correct 297 ms 138368 KB Output is correct
49 Correct 295 ms 138360 KB Output is correct
50 Correct 298 ms 138232 KB Output is correct
51 Correct 190 ms 47096 KB Output is correct
52 Correct 155 ms 27888 KB Output is correct
53 Correct 272 ms 138180 KB Output is correct
54 Correct 265 ms 137692 KB Output is correct
55 Correct 264 ms 137464 KB Output is correct
56 Correct 261 ms 136440 KB Output is correct
57 Runtime error 175 ms 15072 KB Execution killed with signal 11 (could be triggered by violating memory limits)
58 Halted 0 ms 0 KB -