답안 #685336

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
685336 2023-01-24T05:01:25 Z Nursik 벽 칠하기 (APIO20_paint) C++14
28 / 100
1500 ms 32924 KB
#include "paint.h"

#include <vector>
#include <iostream>
#include <set>
#include <map>
#include <cmath>

using namespace std;

#define pb push_back
#define f first
#define s second
#define ll long long

const int maxn = 1e6 + 200, maxm = 1e3 + 200, inf = 1e9;

int n, m, k;
int is[maxn], dp[maxn];
vector<int> g[maxn];
int minimumInstructions(int N, int M, int K, vector<int> C, vector<int> A, vector<vector<int>> B) {
    n = N, m = M, k = K;
    for (int i = 0; i < m; ++i){
        for (auto it : B[i]){
            g[it].pb(i);
        }
    }
    for (int i = m - 1; i < n; ++i){
        for (auto it : g[C[i]]){
            int x = it;
            int ok = 1;
            int z = 0;
           /* if (i == n - 1){
                cout << x << '\n';
            }*/
            while (z < m){
                int ok2 = 0;
                for (auto it2 : B[x]){
                    if (C[i - z] == it2){
                        ok2 = 1;
                        break;
                    }
                }
                if (ok2 == 0){
                    ok = 0;
                    break;
                }
                x = (x - 1 + m) % m;
                z += 1;
            }
            if (ok == 1){
                is[i] = 1;
                break;
            }
        }
    }
    for (int i = 0; i < n; ++i){
        dp[i] = inf;
      //  cout << is[i] << " ";
    }
   // cout << '\n';
    if (is[m - 1] > 0){
        dp[m - 1] = 1;
    }
    for (int i = m - 1; i < n; ++i){
        for (int j = i + 1; j < n && j - i <= m; ++j){
            if (is[j]){
                dp[j] = min(dp[j], dp[i] + 1);
            }
        }
    }
    if (dp[n - 1] == inf){
        dp[n - 1] = -1;
    }
    return dp[n - 1];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 23764 KB Output is correct
2 Correct 13 ms 23756 KB Output is correct
3 Correct 14 ms 23764 KB Output is correct
4 Correct 11 ms 23764 KB Output is correct
5 Correct 11 ms 23764 KB Output is correct
6 Correct 11 ms 23764 KB Output is correct
7 Correct 12 ms 23764 KB Output is correct
8 Correct 11 ms 23764 KB Output is correct
9 Correct 11 ms 23732 KB Output is correct
10 Correct 11 ms 23764 KB Output is correct
11 Correct 11 ms 23816 KB Output is correct
12 Correct 11 ms 23764 KB Output is correct
13 Correct 13 ms 23764 KB Output is correct
14 Correct 11 ms 23764 KB Output is correct
15 Correct 12 ms 23764 KB Output is correct
16 Correct 12 ms 23892 KB Output is correct
17 Correct 13 ms 23860 KB Output is correct
18 Correct 14 ms 23760 KB Output is correct
19 Correct 11 ms 23764 KB Output is correct
20 Correct 11 ms 23764 KB Output is correct
21 Correct 13 ms 23840 KB Output is correct
22 Correct 27 ms 27616 KB Output is correct
23 Correct 28 ms 27732 KB Output is correct
24 Correct 28 ms 27636 KB Output is correct
25 Correct 13 ms 24020 KB Output is correct
26 Correct 13 ms 24116 KB Output is correct
27 Correct 13 ms 24020 KB Output is correct
28 Correct 13 ms 23996 KB Output is correct
29 Correct 13 ms 24020 KB Output is correct
30 Correct 13 ms 24020 KB Output is correct
31 Correct 555 ms 25120 KB Output is correct
32 Correct 555 ms 25008 KB Output is correct
33 Correct 551 ms 25008 KB Output is correct
34 Correct 548 ms 25020 KB Output is correct
35 Correct 547 ms 25064 KB Output is correct
36 Correct 550 ms 24992 KB Output is correct
37 Correct 66 ms 27980 KB Output is correct
38 Correct 67 ms 28092 KB Output is correct
39 Correct 68 ms 28000 KB Output is correct
40 Correct 18 ms 25172 KB Output is correct
41 Correct 15 ms 24656 KB Output is correct
42 Correct 21 ms 25280 KB Output is correct
43 Correct 18 ms 24728 KB Output is correct
44 Correct 16 ms 24680 KB Output is correct
45 Correct 20 ms 25220 KB Output is correct
46 Execution timed out 1588 ms 32924 KB Time limit exceeded
47 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 23764 KB Output is correct
2 Correct 13 ms 23756 KB Output is correct
3 Correct 14 ms 23764 KB Output is correct
4 Correct 11 ms 23764 KB Output is correct
5 Correct 11 ms 23764 KB Output is correct
6 Correct 11 ms 23764 KB Output is correct
7 Correct 12 ms 23764 KB Output is correct
8 Correct 11 ms 23764 KB Output is correct
9 Correct 11 ms 23732 KB Output is correct
10 Correct 11 ms 23764 KB Output is correct
11 Correct 11 ms 23816 KB Output is correct
12 Correct 11 ms 23764 KB Output is correct
13 Correct 13 ms 23764 KB Output is correct
14 Correct 11 ms 23764 KB Output is correct
15 Correct 12 ms 23764 KB Output is correct
16 Correct 12 ms 23892 KB Output is correct
17 Correct 13 ms 23860 KB Output is correct
18 Correct 14 ms 23760 KB Output is correct
19 Correct 11 ms 23764 KB Output is correct
20 Correct 11 ms 23764 KB Output is correct
21 Correct 13 ms 23840 KB Output is correct
22 Correct 13 ms 23764 KB Output is correct
23 Correct 12 ms 23796 KB Output is correct
24 Correct 11 ms 23792 KB Output is correct
25 Correct 11 ms 23764 KB Output is correct
26 Correct 11 ms 23764 KB Output is correct
27 Correct 13 ms 23760 KB Output is correct
28 Correct 12 ms 23780 KB Output is correct
29 Correct 11 ms 23764 KB Output is correct
30 Correct 12 ms 23740 KB Output is correct
31 Correct 11 ms 23792 KB Output is correct
32 Correct 11 ms 23772 KB Output is correct
33 Correct 12 ms 23796 KB Output is correct
34 Correct 12 ms 23800 KB Output is correct
35 Correct 12 ms 23820 KB Output is correct
36 Correct 12 ms 23764 KB Output is correct
37 Correct 12 ms 23800 KB Output is correct
38 Correct 12 ms 23764 KB Output is correct
39 Correct 11 ms 23740 KB Output is correct
40 Correct 12 ms 23816 KB Output is correct
41 Correct 11 ms 23764 KB Output is correct
42 Correct 11 ms 23772 KB Output is correct
43 Correct 12 ms 23892 KB Output is correct
44 Correct 11 ms 23756 KB Output is correct
45 Correct 12 ms 23764 KB Output is correct
46 Correct 11 ms 23768 KB Output is correct
47 Correct 11 ms 23764 KB Output is correct
48 Correct 12 ms 23764 KB Output is correct
49 Correct 11 ms 23764 KB Output is correct
50 Correct 13 ms 23796 KB Output is correct
51 Correct 12 ms 23764 KB Output is correct
52 Correct 12 ms 23764 KB Output is correct
53 Correct 12 ms 23764 KB Output is correct
54 Correct 14 ms 23796 KB Output is correct
55 Correct 12 ms 23800 KB Output is correct
56 Correct 13 ms 23764 KB Output is correct
57 Correct 12 ms 23740 KB Output is correct
58 Correct 11 ms 23764 KB Output is correct
59 Correct 12 ms 23800 KB Output is correct
60 Correct 12 ms 23868 KB Output is correct
61 Correct 12 ms 23764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 23764 KB Output is correct
2 Correct 12 ms 23796 KB Output is correct
3 Correct 11 ms 23764 KB Output is correct
4 Correct 13 ms 23756 KB Output is correct
5 Correct 14 ms 23764 KB Output is correct
6 Correct 11 ms 23764 KB Output is correct
7 Correct 11 ms 23764 KB Output is correct
8 Correct 11 ms 23764 KB Output is correct
9 Correct 12 ms 23764 KB Output is correct
10 Correct 11 ms 23764 KB Output is correct
11 Correct 11 ms 23732 KB Output is correct
12 Correct 11 ms 23764 KB Output is correct
13 Correct 11 ms 23816 KB Output is correct
14 Correct 11 ms 23764 KB Output is correct
15 Correct 13 ms 23764 KB Output is correct
16 Correct 11 ms 23764 KB Output is correct
17 Correct 12 ms 23764 KB Output is correct
18 Correct 12 ms 23892 KB Output is correct
19 Correct 13 ms 23860 KB Output is correct
20 Correct 14 ms 23760 KB Output is correct
21 Correct 11 ms 23764 KB Output is correct
22 Correct 11 ms 23764 KB Output is correct
23 Correct 13 ms 23840 KB Output is correct
24 Correct 27 ms 27616 KB Output is correct
25 Correct 28 ms 27732 KB Output is correct
26 Correct 28 ms 27636 KB Output is correct
27 Correct 11 ms 23792 KB Output is correct
28 Correct 11 ms 23764 KB Output is correct
29 Correct 11 ms 23764 KB Output is correct
30 Correct 13 ms 23760 KB Output is correct
31 Correct 12 ms 23780 KB Output is correct
32 Correct 11 ms 23764 KB Output is correct
33 Correct 12 ms 23740 KB Output is correct
34 Correct 11 ms 23792 KB Output is correct
35 Correct 11 ms 23772 KB Output is correct
36 Correct 12 ms 23796 KB Output is correct
37 Correct 12 ms 23800 KB Output is correct
38 Correct 12 ms 23820 KB Output is correct
39 Correct 12 ms 23764 KB Output is correct
40 Correct 12 ms 23800 KB Output is correct
41 Correct 12 ms 23764 KB Output is correct
42 Correct 11 ms 23740 KB Output is correct
43 Correct 12 ms 23816 KB Output is correct
44 Correct 11 ms 23764 KB Output is correct
45 Correct 11 ms 23772 KB Output is correct
46 Correct 12 ms 23892 KB Output is correct
47 Correct 11 ms 23756 KB Output is correct
48 Correct 12 ms 23764 KB Output is correct
49 Correct 11 ms 23768 KB Output is correct
50 Correct 11 ms 23764 KB Output is correct
51 Correct 12 ms 23764 KB Output is correct
52 Correct 11 ms 23764 KB Output is correct
53 Correct 13 ms 23796 KB Output is correct
54 Correct 12 ms 23764 KB Output is correct
55 Correct 12 ms 23764 KB Output is correct
56 Correct 12 ms 23764 KB Output is correct
57 Correct 14 ms 23796 KB Output is correct
58 Correct 12 ms 23800 KB Output is correct
59 Correct 13 ms 23764 KB Output is correct
60 Correct 12 ms 23740 KB Output is correct
61 Correct 11 ms 23764 KB Output is correct
62 Correct 12 ms 23800 KB Output is correct
63 Correct 12 ms 23868 KB Output is correct
64 Correct 12 ms 23764 KB Output is correct
65 Correct 11 ms 23792 KB Output is correct
66 Correct 11 ms 23808 KB Output is correct
67 Correct 12 ms 23764 KB Output is correct
68 Correct 12 ms 23832 KB Output is correct
69 Correct 12 ms 23820 KB Output is correct
70 Correct 17 ms 24020 KB Output is correct
71 Correct 17 ms 24064 KB Output is correct
72 Correct 16 ms 23964 KB Output is correct
73 Correct 13 ms 23840 KB Output is correct
74 Correct 16 ms 23936 KB Output is correct
75 Correct 16 ms 24020 KB Output is correct
76 Correct 29 ms 27092 KB Output is correct
77 Correct 45 ms 27520 KB Output is correct
78 Correct 34 ms 28120 KB Output is correct
79 Correct 12 ms 23816 KB Output is correct
80 Correct 12 ms 23768 KB Output is correct
81 Correct 12 ms 23764 KB Output is correct
82 Correct 12 ms 23848 KB Output is correct
83 Correct 12 ms 23796 KB Output is correct
84 Correct 19 ms 24132 KB Output is correct
85 Correct 19 ms 24064 KB Output is correct
86 Correct 22 ms 24044 KB Output is correct
87 Correct 21 ms 24052 KB Output is correct
88 Correct 17 ms 24016 KB Output is correct
89 Correct 21 ms 24016 KB Output is correct
90 Correct 37 ms 28432 KB Output is correct
91 Correct 36 ms 28336 KB Output is correct
92 Correct 38 ms 28452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 23764 KB Output is correct
2 Correct 12 ms 23796 KB Output is correct
3 Correct 11 ms 23764 KB Output is correct
4 Correct 13 ms 23756 KB Output is correct
5 Correct 14 ms 23764 KB Output is correct
6 Correct 11 ms 23764 KB Output is correct
7 Correct 11 ms 23764 KB Output is correct
8 Correct 11 ms 23764 KB Output is correct
9 Correct 12 ms 23764 KB Output is correct
10 Correct 11 ms 23764 KB Output is correct
11 Correct 11 ms 23732 KB Output is correct
12 Correct 11 ms 23764 KB Output is correct
13 Correct 11 ms 23816 KB Output is correct
14 Correct 11 ms 23764 KB Output is correct
15 Correct 13 ms 23764 KB Output is correct
16 Correct 11 ms 23764 KB Output is correct
17 Correct 12 ms 23764 KB Output is correct
18 Correct 12 ms 23892 KB Output is correct
19 Correct 13 ms 23860 KB Output is correct
20 Correct 14 ms 23760 KB Output is correct
21 Correct 11 ms 23764 KB Output is correct
22 Correct 11 ms 23764 KB Output is correct
23 Correct 13 ms 23840 KB Output is correct
24 Correct 27 ms 27616 KB Output is correct
25 Correct 28 ms 27732 KB Output is correct
26 Correct 28 ms 27636 KB Output is correct
27 Correct 13 ms 24020 KB Output is correct
28 Correct 13 ms 24116 KB Output is correct
29 Correct 13 ms 24020 KB Output is correct
30 Correct 13 ms 23996 KB Output is correct
31 Correct 13 ms 24020 KB Output is correct
32 Correct 13 ms 24020 KB Output is correct
33 Correct 555 ms 25120 KB Output is correct
34 Correct 555 ms 25008 KB Output is correct
35 Correct 551 ms 25008 KB Output is correct
36 Correct 548 ms 25020 KB Output is correct
37 Correct 547 ms 25064 KB Output is correct
38 Correct 550 ms 24992 KB Output is correct
39 Correct 66 ms 27980 KB Output is correct
40 Correct 67 ms 28092 KB Output is correct
41 Correct 68 ms 28000 KB Output is correct
42 Correct 11 ms 23792 KB Output is correct
43 Correct 11 ms 23764 KB Output is correct
44 Correct 11 ms 23764 KB Output is correct
45 Correct 13 ms 23760 KB Output is correct
46 Correct 12 ms 23780 KB Output is correct
47 Correct 11 ms 23764 KB Output is correct
48 Correct 12 ms 23740 KB Output is correct
49 Correct 11 ms 23792 KB Output is correct
50 Correct 11 ms 23772 KB Output is correct
51 Correct 12 ms 23796 KB Output is correct
52 Correct 12 ms 23800 KB Output is correct
53 Correct 12 ms 23820 KB Output is correct
54 Correct 12 ms 23764 KB Output is correct
55 Correct 12 ms 23800 KB Output is correct
56 Correct 12 ms 23764 KB Output is correct
57 Correct 11 ms 23740 KB Output is correct
58 Correct 12 ms 23816 KB Output is correct
59 Correct 11 ms 23764 KB Output is correct
60 Correct 11 ms 23772 KB Output is correct
61 Correct 12 ms 23892 KB Output is correct
62 Correct 11 ms 23756 KB Output is correct
63 Correct 12 ms 23764 KB Output is correct
64 Correct 11 ms 23768 KB Output is correct
65 Correct 11 ms 23764 KB Output is correct
66 Correct 12 ms 23764 KB Output is correct
67 Correct 11 ms 23764 KB Output is correct
68 Correct 13 ms 23796 KB Output is correct
69 Correct 12 ms 23764 KB Output is correct
70 Correct 12 ms 23764 KB Output is correct
71 Correct 12 ms 23764 KB Output is correct
72 Correct 14 ms 23796 KB Output is correct
73 Correct 12 ms 23800 KB Output is correct
74 Correct 13 ms 23764 KB Output is correct
75 Correct 12 ms 23740 KB Output is correct
76 Correct 11 ms 23764 KB Output is correct
77 Correct 12 ms 23800 KB Output is correct
78 Correct 12 ms 23868 KB Output is correct
79 Correct 12 ms 23764 KB Output is correct
80 Correct 11 ms 23792 KB Output is correct
81 Correct 11 ms 23808 KB Output is correct
82 Correct 12 ms 23764 KB Output is correct
83 Correct 12 ms 23832 KB Output is correct
84 Correct 12 ms 23820 KB Output is correct
85 Correct 17 ms 24020 KB Output is correct
86 Correct 17 ms 24064 KB Output is correct
87 Correct 16 ms 23964 KB Output is correct
88 Correct 13 ms 23840 KB Output is correct
89 Correct 16 ms 23936 KB Output is correct
90 Correct 16 ms 24020 KB Output is correct
91 Correct 29 ms 27092 KB Output is correct
92 Correct 45 ms 27520 KB Output is correct
93 Correct 34 ms 28120 KB Output is correct
94 Correct 12 ms 23816 KB Output is correct
95 Correct 12 ms 23768 KB Output is correct
96 Correct 12 ms 23764 KB Output is correct
97 Correct 12 ms 23848 KB Output is correct
98 Correct 12 ms 23796 KB Output is correct
99 Correct 19 ms 24132 KB Output is correct
100 Correct 19 ms 24064 KB Output is correct
101 Correct 22 ms 24044 KB Output is correct
102 Correct 21 ms 24052 KB Output is correct
103 Correct 17 ms 24016 KB Output is correct
104 Correct 21 ms 24016 KB Output is correct
105 Correct 37 ms 28432 KB Output is correct
106 Correct 36 ms 28336 KB Output is correct
107 Correct 38 ms 28452 KB Output is correct
108 Correct 13 ms 24060 KB Output is correct
109 Correct 61 ms 24036 KB Output is correct
110 Correct 141 ms 24112 KB Output is correct
111 Correct 98 ms 23992 KB Output is correct
112 Correct 109 ms 24140 KB Output is correct
113 Correct 62 ms 24004 KB Output is correct
114 Correct 645 ms 25460 KB Output is correct
115 Correct 499 ms 25348 KB Output is correct
116 Correct 1141 ms 25944 KB Output is correct
117 Correct 549 ms 25680 KB Output is correct
118 Correct 599 ms 25688 KB Output is correct
119 Correct 579 ms 25404 KB Output is correct
120 Correct 46 ms 26760 KB Output is correct
121 Correct 227 ms 24508 KB Output is correct
122 Correct 44 ms 27180 KB Output is correct
123 Correct 131 ms 24372 KB Output is correct
124 Correct 64 ms 27756 KB Output is correct
125 Correct 204 ms 24804 KB Output is correct
126 Correct 123 ms 24820 KB Output is correct
127 Correct 255 ms 25288 KB Output is correct
128 Correct 112 ms 24840 KB Output is correct
129 Correct 130 ms 24740 KB Output is correct
130 Correct 13 ms 24060 KB Output is correct
131 Correct 82 ms 24224 KB Output is correct
132 Correct 221 ms 24140 KB Output is correct
133 Correct 162 ms 24168 KB Output is correct
134 Correct 134 ms 24108 KB Output is correct
135 Correct 121 ms 24124 KB Output is correct
136 Correct 1473 ms 26152 KB Output is correct
137 Execution timed out 1588 ms 26188 KB Time limit exceeded
138 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 23764 KB Output is correct
2 Correct 12 ms 23796 KB Output is correct
3 Correct 11 ms 23764 KB Output is correct
4 Correct 13 ms 23756 KB Output is correct
5 Correct 14 ms 23764 KB Output is correct
6 Correct 11 ms 23764 KB Output is correct
7 Correct 11 ms 23764 KB Output is correct
8 Correct 11 ms 23764 KB Output is correct
9 Correct 12 ms 23764 KB Output is correct
10 Correct 11 ms 23764 KB Output is correct
11 Correct 11 ms 23732 KB Output is correct
12 Correct 11 ms 23764 KB Output is correct
13 Correct 11 ms 23816 KB Output is correct
14 Correct 11 ms 23764 KB Output is correct
15 Correct 13 ms 23764 KB Output is correct
16 Correct 11 ms 23764 KB Output is correct
17 Correct 12 ms 23764 KB Output is correct
18 Correct 12 ms 23892 KB Output is correct
19 Correct 13 ms 23860 KB Output is correct
20 Correct 14 ms 23760 KB Output is correct
21 Correct 11 ms 23764 KB Output is correct
22 Correct 11 ms 23764 KB Output is correct
23 Correct 13 ms 23840 KB Output is correct
24 Correct 27 ms 27616 KB Output is correct
25 Correct 28 ms 27732 KB Output is correct
26 Correct 28 ms 27636 KB Output is correct
27 Correct 13 ms 24020 KB Output is correct
28 Correct 13 ms 24116 KB Output is correct
29 Correct 13 ms 24020 KB Output is correct
30 Correct 13 ms 23996 KB Output is correct
31 Correct 13 ms 24020 KB Output is correct
32 Correct 13 ms 24020 KB Output is correct
33 Correct 555 ms 25120 KB Output is correct
34 Correct 555 ms 25008 KB Output is correct
35 Correct 551 ms 25008 KB Output is correct
36 Correct 548 ms 25020 KB Output is correct
37 Correct 547 ms 25064 KB Output is correct
38 Correct 550 ms 24992 KB Output is correct
39 Correct 66 ms 27980 KB Output is correct
40 Correct 67 ms 28092 KB Output is correct
41 Correct 68 ms 28000 KB Output is correct
42 Correct 18 ms 25172 KB Output is correct
43 Correct 15 ms 24656 KB Output is correct
44 Correct 21 ms 25280 KB Output is correct
45 Correct 18 ms 24728 KB Output is correct
46 Correct 16 ms 24680 KB Output is correct
47 Correct 20 ms 25220 KB Output is correct
48 Execution timed out 1588 ms 32924 KB Time limit exceeded
49 Halted 0 ms 0 KB -