# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
291921 | 2020-09-06T03:11:32 Z | anonymous | Rope (JOI17_rope) | C++14 | 2500 ms | 1152 KB |
#include <iostream> #define MAXN 1000005 #define MAXM 15 using namespace std; int N, M, C[MAXN], Ans[MAXM]; int main() { //freopen("ropein.txt","r",stdin); scanf("%d %d",&N,&M); for (int i=1; i<=M; i++) { Ans[i] = N; } for (int i=1; i<=N; i++) { scanf("%d",&C[i]); Ans[C[i]] -= 1; } for (int i=1; i<=M; i++) { for (int j=i+1; j <= M; j++) { //case 1: A[1] = A[2] ... int ans1 = 0, ans2 = 0; for (int k=1; k<N; k+=2) { if (C[k] != i && C[k] != j && C[k+1] != i && C[k+1] != j) {ans1+=2;} else if (C[k] != C[k+1]) {ans1 += 1;} } if (N%2 && C[N] != i && C[N] != j) {ans1++;} //case 2: A[2] = A[3] ... for (int k=2; k<N; k+=2) { if (C[k] != i && C[k] != j && C[k+1] != i && C[k+1] != j) {ans2+=2;} else if (C[k] != C[k+1]) {ans2 += 1;} } if (C[1] != i && C[1] != j) {ans2++;} if (N%2 == 0 && C[N] != i && C[N] != j) {ans2++;} Ans[i] = min(Ans[i], min(ans1,ans2)); Ans[j] = min(Ans[j], min(ans1,ans2)); //printf("%d %d %d %d\n",i,j,ans1,ans2); } } for (int i=1; i<=M; i++) { printf("%d\n",Ans[i]); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 1 ms | 256 KB | Output is correct |
3 | Correct | 1 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 0 ms | 256 KB | Output is correct |
8 | Correct | 1 ms | 256 KB | Output is correct |
9 | Correct | 1 ms | 256 KB | Output is correct |
10 | Correct | 0 ms | 256 KB | Output is correct |
11 | Correct | 1 ms | 256 KB | Output is correct |
12 | Correct | 0 ms | 256 KB | Output is correct |
13 | Correct | 0 ms | 256 KB | Output is correct |
14 | Correct | 0 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
16 | Correct | 0 ms | 256 KB | Output is correct |
17 | Correct | 0 ms | 384 KB | Output is correct |
18 | Correct | 1 ms | 256 KB | Output is correct |
19 | Correct | 0 ms | 256 KB | Output is correct |
20 | Correct | 0 ms | 256 KB | Output is correct |
21 | Correct | 1 ms | 384 KB | Output is correct |
22 | Correct | 1 ms | 256 KB | Output is correct |
23 | Correct | 1 ms | 256 KB | Output is correct |
24 | Correct | 0 ms | 256 KB | Output is correct |
25 | Correct | 0 ms | 384 KB | Output is correct |
26 | Correct | 1 ms | 256 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 1 ms | 256 KB | Output is correct |
3 | Correct | 1 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 0 ms | 256 KB | Output is correct |
8 | Correct | 1 ms | 256 KB | Output is correct |
9 | Correct | 1 ms | 256 KB | Output is correct |
10 | Correct | 0 ms | 256 KB | Output is correct |
11 | Correct | 1 ms | 256 KB | Output is correct |
12 | Correct | 0 ms | 256 KB | Output is correct |
13 | Correct | 0 ms | 256 KB | Output is correct |
14 | Correct | 0 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
16 | Correct | 0 ms | 256 KB | Output is correct |
17 | Correct | 0 ms | 384 KB | Output is correct |
18 | Correct | 1 ms | 256 KB | Output is correct |
19 | Correct | 0 ms | 256 KB | Output is correct |
20 | Correct | 0 ms | 256 KB | Output is correct |
21 | Correct | 1 ms | 384 KB | Output is correct |
22 | Correct | 1 ms | 256 KB | Output is correct |
23 | Correct | 1 ms | 256 KB | Output is correct |
24 | Correct | 0 ms | 256 KB | Output is correct |
25 | Correct | 0 ms | 384 KB | Output is correct |
26 | Correct | 1 ms | 256 KB | Output is correct |
27 | Correct | 34 ms | 896 KB | Output is correct |
28 | Correct | 16 ms | 896 KB | Output is correct |
29 | Correct | 34 ms | 896 KB | Output is correct |
30 | Correct | 19 ms | 896 KB | Output is correct |
31 | Correct | 34 ms | 896 KB | Output is correct |
32 | Correct | 16 ms | 896 KB | Output is correct |
33 | Correct | 32 ms | 956 KB | Output is correct |
34 | Correct | 20 ms | 1024 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 1 ms | 256 KB | Output is correct |
3 | Correct | 1 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 0 ms | 256 KB | Output is correct |
8 | Correct | 1 ms | 256 KB | Output is correct |
9 | Correct | 1 ms | 256 KB | Output is correct |
10 | Correct | 0 ms | 256 KB | Output is correct |
11 | Correct | 1 ms | 256 KB | Output is correct |
12 | Correct | 0 ms | 256 KB | Output is correct |
13 | Correct | 0 ms | 256 KB | Output is correct |
14 | Correct | 0 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
16 | Correct | 0 ms | 256 KB | Output is correct |
17 | Correct | 0 ms | 384 KB | Output is correct |
18 | Correct | 1 ms | 256 KB | Output is correct |
19 | Correct | 0 ms | 256 KB | Output is correct |
20 | Correct | 0 ms | 256 KB | Output is correct |
21 | Correct | 1 ms | 384 KB | Output is correct |
22 | Correct | 1 ms | 256 KB | Output is correct |
23 | Correct | 1 ms | 256 KB | Output is correct |
24 | Correct | 0 ms | 256 KB | Output is correct |
25 | Correct | 0 ms | 384 KB | Output is correct |
26 | Correct | 1 ms | 256 KB | Output is correct |
27 | Correct | 34 ms | 896 KB | Output is correct |
28 | Correct | 16 ms | 896 KB | Output is correct |
29 | Correct | 34 ms | 896 KB | Output is correct |
30 | Correct | 19 ms | 896 KB | Output is correct |
31 | Correct | 34 ms | 896 KB | Output is correct |
32 | Correct | 16 ms | 896 KB | Output is correct |
33 | Correct | 32 ms | 956 KB | Output is correct |
34 | Correct | 20 ms | 1024 KB | Output is correct |
35 | Execution timed out | 2569 ms | 1152 KB | Time limit exceeded |
36 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 1 ms | 256 KB | Output is correct |
3 | Correct | 1 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 0 ms | 256 KB | Output is correct |
8 | Correct | 1 ms | 256 KB | Output is correct |
9 | Correct | 1 ms | 256 KB | Output is correct |
10 | Correct | 0 ms | 256 KB | Output is correct |
11 | Correct | 1 ms | 256 KB | Output is correct |
12 | Correct | 0 ms | 256 KB | Output is correct |
13 | Correct | 0 ms | 256 KB | Output is correct |
14 | Correct | 0 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
16 | Correct | 0 ms | 256 KB | Output is correct |
17 | Correct | 0 ms | 384 KB | Output is correct |
18 | Correct | 1 ms | 256 KB | Output is correct |
19 | Correct | 0 ms | 256 KB | Output is correct |
20 | Correct | 0 ms | 256 KB | Output is correct |
21 | Correct | 1 ms | 384 KB | Output is correct |
22 | Correct | 1 ms | 256 KB | Output is correct |
23 | Correct | 1 ms | 256 KB | Output is correct |
24 | Correct | 0 ms | 256 KB | Output is correct |
25 | Correct | 0 ms | 384 KB | Output is correct |
26 | Correct | 1 ms | 256 KB | Output is correct |
27 | Correct | 34 ms | 896 KB | Output is correct |
28 | Correct | 16 ms | 896 KB | Output is correct |
29 | Correct | 34 ms | 896 KB | Output is correct |
30 | Correct | 19 ms | 896 KB | Output is correct |
31 | Correct | 34 ms | 896 KB | Output is correct |
32 | Correct | 16 ms | 896 KB | Output is correct |
33 | Correct | 32 ms | 956 KB | Output is correct |
34 | Correct | 20 ms | 1024 KB | Output is correct |
35 | Execution timed out | 2569 ms | 1152 KB | Time limit exceeded |
36 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 1 ms | 256 KB | Output is correct |
3 | Correct | 1 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 0 ms | 256 KB | Output is correct |
8 | Correct | 1 ms | 256 KB | Output is correct |
9 | Correct | 1 ms | 256 KB | Output is correct |
10 | Correct | 0 ms | 256 KB | Output is correct |
11 | Correct | 1 ms | 256 KB | Output is correct |
12 | Correct | 0 ms | 256 KB | Output is correct |
13 | Correct | 0 ms | 256 KB | Output is correct |
14 | Correct | 0 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
16 | Correct | 0 ms | 256 KB | Output is correct |
17 | Correct | 0 ms | 384 KB | Output is correct |
18 | Correct | 1 ms | 256 KB | Output is correct |
19 | Correct | 0 ms | 256 KB | Output is correct |
20 | Correct | 0 ms | 256 KB | Output is correct |
21 | Correct | 1 ms | 384 KB | Output is correct |
22 | Correct | 1 ms | 256 KB | Output is correct |
23 | Correct | 1 ms | 256 KB | Output is correct |
24 | Correct | 0 ms | 256 KB | Output is correct |
25 | Correct | 0 ms | 384 KB | Output is correct |
26 | Correct | 1 ms | 256 KB | Output is correct |
27 | Correct | 34 ms | 896 KB | Output is correct |
28 | Correct | 16 ms | 896 KB | Output is correct |
29 | Correct | 34 ms | 896 KB | Output is correct |
30 | Correct | 19 ms | 896 KB | Output is correct |
31 | Correct | 34 ms | 896 KB | Output is correct |
32 | Correct | 16 ms | 896 KB | Output is correct |
33 | Correct | 32 ms | 956 KB | Output is correct |
34 | Correct | 20 ms | 1024 KB | Output is correct |
35 | Execution timed out | 2569 ms | 1152 KB | Time limit exceeded |
36 | Halted | 0 ms | 0 KB | - |