답안 #949324

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
949324 2024-03-19T06:14:42 Z vjudge1 벽 칠하기 (APIO20_paint) C++17
28 / 100
1500 ms 8928 KB
#include <bits/stdc++.h>

#include "paint.h"


using namespace std;

const int inf = 1e9;


int minimumInstructions(
    int N, int M, int K, std::vector<int> C,
    std::vector<int> A, std::vector<std::vector<int>> B) {
	vector <int> dp(N + 1, inf);
	set <int> st[M];
	for(int i = 0; i < M; i++){
		for(auto x : B[i]){
			st[i].insert(x);
		}
	}
	for(int i = 0; i + M - 1 < N; i++){
		for(int j = 0; j < M; j++){
			bool flag = 1;
			for(int l = 0; l < M; l++){
				if(st[(l + j) % M].find(C[i + l]) == st[(l + j) % M].end()){
					flag = 0;
					break;
				}
			}
			if(flag){
				if(i == 0)
					dp[i + M - 1] = 1;
				else{
					for(int j = i - 1; j < i + M - 1; j++){
						dp[i + M - 1] = min(dp[j] + 1,dp[i + M - 1]);
						//cout << dp[j] <<"=" << j << endl;
					}
				}
				//cout << i <<"-"<< dp[i + M - 1] << endl;
				//break;
			}
		}
	}
	if(dp[N - 1] == inf)
		return -1;
	return dp[N - 1];
}


/*
int main() {
  int N, M, K;
  assert(3 == scanf("%d %d %d", &N, &M, &K));
  
  std::vector<int> C(N);
  for (int i = 0; i < N; ++i) {
    assert(1 == scanf("%d", &C[i]));
  }

  std::vector<int> A(M);
  std::vector<std::vector<int>> B(M);
  for (int i = 0; i < M; ++i) {
    assert(1 == scanf("%d", &A[i]));
    B[i].resize(A[i]);
    for (int j = 0; j < A[i]; ++j) {
      assert(1 == scanf("%d", &B[i][j]));
    }
  }

  int minimum_instructions = minimumInstructions(N, M, K, C, A, B);
  printf("%d\n", minimum_instructions);
  
  return 0;
}
*/

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 2 ms 344 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 1 ms 488 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 2 ms 348 KB Output is correct
22 Correct 24 ms 5724 KB Output is correct
23 Correct 21 ms 5724 KB Output is correct
24 Correct 22 ms 5724 KB Output is correct
25 Correct 2 ms 604 KB Output is correct
26 Correct 2 ms 604 KB Output is correct
27 Correct 2 ms 604 KB Output is correct
28 Correct 2 ms 604 KB Output is correct
29 Correct 2 ms 604 KB Output is correct
30 Correct 2 ms 668 KB Output is correct
31 Correct 1433 ms 1972 KB Output is correct
32 Correct 1392 ms 1968 KB Output is correct
33 Correct 1403 ms 2128 KB Output is correct
34 Correct 1405 ms 1972 KB Output is correct
35 Correct 1425 ms 1984 KB Output is correct
36 Correct 1429 ms 1968 KB Output is correct
37 Execution timed out 1537 ms 6232 KB Time limit exceeded
38 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 2 ms 344 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 1 ms 488 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 2 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 600 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 396 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 1 ms 344 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 0 ms 600 KB Output is correct
45 Correct 3 ms 344 KB Output is correct
46 Correct 1 ms 348 KB Output is correct
47 Correct 1 ms 348 KB Output is correct
48 Correct 1 ms 348 KB Output is correct
49 Correct 1 ms 348 KB Output is correct
50 Correct 1 ms 488 KB Output is correct
51 Correct 1 ms 348 KB Output is correct
52 Correct 2 ms 348 KB Output is correct
53 Correct 2 ms 344 KB Output is correct
54 Correct 2 ms 348 KB Output is correct
55 Correct 1 ms 348 KB Output is correct
56 Correct 2 ms 348 KB Output is correct
57 Correct 1 ms 348 KB Output is correct
58 Correct 2 ms 348 KB Output is correct
59 Correct 2 ms 348 KB Output is correct
60 Correct 2 ms 348 KB Output is correct
61 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 600 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 2 ms 344 KB Output is correct
17 Correct 2 ms 348 KB Output is correct
18 Correct 1 ms 488 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 2 ms 348 KB Output is correct
24 Correct 24 ms 5724 KB Output is correct
25 Correct 21 ms 5724 KB Output is correct
26 Correct 22 ms 5724 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 600 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 396 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 1 ms 344 KB Output is correct
46 Correct 1 ms 348 KB Output is correct
47 Correct 0 ms 600 KB Output is correct
48 Correct 3 ms 344 KB Output is correct
49 Correct 1 ms 348 KB Output is correct
50 Correct 1 ms 348 KB Output is correct
51 Correct 1 ms 348 KB Output is correct
52 Correct 1 ms 348 KB Output is correct
53 Correct 1 ms 488 KB Output is correct
54 Correct 1 ms 348 KB Output is correct
55 Correct 2 ms 348 KB Output is correct
56 Correct 2 ms 344 KB Output is correct
57 Correct 2 ms 348 KB Output is correct
58 Correct 1 ms 348 KB Output is correct
59 Correct 2 ms 348 KB Output is correct
60 Correct 1 ms 348 KB Output is correct
61 Correct 2 ms 348 KB Output is correct
62 Correct 2 ms 348 KB Output is correct
63 Correct 2 ms 348 KB Output is correct
64 Correct 1 ms 348 KB Output is correct
65 Correct 13 ms 348 KB Output is correct
66 Correct 4 ms 348 KB Output is correct
67 Correct 31 ms 344 KB Output is correct
68 Correct 12 ms 348 KB Output is correct
69 Correct 27 ms 348 KB Output is correct
70 Correct 33 ms 856 KB Output is correct
71 Correct 37 ms 860 KB Output is correct
72 Correct 25 ms 1016 KB Output is correct
73 Correct 3 ms 604 KB Output is correct
74 Correct 28 ms 1040 KB Output is correct
75 Correct 22 ms 860 KB Output is correct
76 Correct 19 ms 6492 KB Output is correct
77 Correct 26 ms 6936 KB Output is correct
78 Correct 26 ms 8284 KB Output is correct
79 Correct 64 ms 464 KB Output is correct
80 Correct 66 ms 460 KB Output is correct
81 Correct 66 ms 548 KB Output is correct
82 Correct 66 ms 476 KB Output is correct
83 Correct 72 ms 344 KB Output is correct
84 Correct 74 ms 1116 KB Output is correct
85 Correct 60 ms 1112 KB Output is correct
86 Correct 59 ms 1112 KB Output is correct
87 Correct 57 ms 1268 KB Output is correct
88 Correct 58 ms 1112 KB Output is correct
89 Correct 61 ms 1368 KB Output is correct
90 Correct 30 ms 8928 KB Output is correct
91 Correct 30 ms 8784 KB Output is correct
92 Correct 32 ms 8792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 600 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 2 ms 344 KB Output is correct
17 Correct 2 ms 348 KB Output is correct
18 Correct 1 ms 488 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 2 ms 348 KB Output is correct
24 Correct 24 ms 5724 KB Output is correct
25 Correct 21 ms 5724 KB Output is correct
26 Correct 22 ms 5724 KB Output is correct
27 Correct 2 ms 604 KB Output is correct
28 Correct 2 ms 604 KB Output is correct
29 Correct 2 ms 604 KB Output is correct
30 Correct 2 ms 604 KB Output is correct
31 Correct 2 ms 604 KB Output is correct
32 Correct 2 ms 668 KB Output is correct
33 Correct 1433 ms 1972 KB Output is correct
34 Correct 1392 ms 1968 KB Output is correct
35 Correct 1403 ms 2128 KB Output is correct
36 Correct 1405 ms 1972 KB Output is correct
37 Correct 1425 ms 1984 KB Output is correct
38 Correct 1429 ms 1968 KB Output is correct
39 Execution timed out 1537 ms 6232 KB Time limit exceeded
40 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 600 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 2 ms 344 KB Output is correct
17 Correct 2 ms 348 KB Output is correct
18 Correct 1 ms 488 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 2 ms 348 KB Output is correct
24 Correct 24 ms 5724 KB Output is correct
25 Correct 21 ms 5724 KB Output is correct
26 Correct 22 ms 5724 KB Output is correct
27 Correct 2 ms 604 KB Output is correct
28 Correct 2 ms 604 KB Output is correct
29 Correct 2 ms 604 KB Output is correct
30 Correct 2 ms 604 KB Output is correct
31 Correct 2 ms 604 KB Output is correct
32 Correct 2 ms 668 KB Output is correct
33 Correct 1433 ms 1972 KB Output is correct
34 Correct 1392 ms 1968 KB Output is correct
35 Correct 1403 ms 2128 KB Output is correct
36 Correct 1405 ms 1972 KB Output is correct
37 Correct 1425 ms 1984 KB Output is correct
38 Correct 1429 ms 1968 KB Output is correct
39 Execution timed out 1537 ms 6232 KB Time limit exceeded
40 Halted 0 ms 0 KB -