답안 #397338

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
397338 2021-05-01T22:44:51 Z rocks03 벽 칠하기 (APIO20_paint) C++14
28 / 100
1500 ms 2380 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define pb push_back
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << ": " << x << " "
#define nl cout << "\n"
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define per(i, a, b) for(int i = (a); i >= (b); i--)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int minimumInstructions(int N, int M, int K, vector<int> C, vector<int> A, vector<vector<int>> B){
    vector<pii> v;
    rep(y, 0, N - M + 1){
        rep(x, 0, M){
            bool ok = true;
            rep(l, 0, M){
                int i = (x + l) % M, j = y + l;
                auto it = lower_bound(all(B[i]), C[j]);
                if(it != B[i].end() && *it == C[j]) continue;
                ok = false; break;
            }
            if(ok){
                v.pb({y, y + M - 1});
                break;
            }
        }
    }
    sort(all(v));
    vector<int> dp(SZ(v), INT_MAX);
    rep(i, 0, SZ(v)){
        auto [l, r] = v[i];
        if(l == 0) dp[i] = 1;
    }
    rep(i, 0, SZ(v)){
        if(dp[i] == INT_MAX) continue;
        auto [l, r] = v[i];
        rep(j, i + 1, SZ(v)){
            auto [ql, qr] = v[j];
            if(r + 1 >= ql){
                dp[j] = min(dp[j], dp[i] + 1);
            }
        }
    }
    int ans = INT_MAX;
    rep(i, 0, SZ(v)){
        auto [l, r] = v[i];
        if(r == N - 1) ans = min(ans, dp[i]);
    }
    if(ans == INT_MAX) ans = -1;
    return ans;
}

Compilation message

paint.cpp: In function 'int minimumInstructions(int, int, int, std::vector<int>, std::vector<int>, std::vector<std::vector<int> >)':
paint.cpp:37:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   37 |         auto [l, r] = v[i];
      |              ^
paint.cpp:42:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   42 |         auto [l, r] = v[i];
      |              ^
paint.cpp:44:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   44 |             auto [ql, qr] = v[j];
      |                  ^
paint.cpp:52:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   52 |         auto [l, r] = v[i];
      |              ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 2 ms 204 KB Output is correct
14 Correct 2 ms 204 KB Output is correct
15 Correct 2 ms 204 KB Output is correct
16 Correct 2 ms 332 KB Output is correct
17 Correct 2 ms 332 KB Output is correct
18 Correct 2 ms 332 KB Output is correct
19 Correct 2 ms 204 KB Output is correct
20 Correct 3 ms 204 KB Output is correct
21 Correct 2 ms 204 KB Output is correct
22 Correct 20 ms 972 KB Output is correct
23 Correct 17 ms 1096 KB Output is correct
24 Correct 16 ms 1100 KB Output is correct
25 Correct 227 ms 844 KB Output is correct
26 Correct 214 ms 848 KB Output is correct
27 Correct 4 ms 588 KB Output is correct
28 Correct 4 ms 460 KB Output is correct
29 Correct 4 ms 332 KB Output is correct
30 Correct 4 ms 332 KB Output is correct
31 Correct 1253 ms 1240 KB Output is correct
32 Correct 1227 ms 1348 KB Output is correct
33 Correct 1234 ms 1464 KB Output is correct
34 Correct 1285 ms 1480 KB Output is correct
35 Correct 1243 ms 1372 KB Output is correct
36 Correct 1226 ms 1360 KB Output is correct
37 Correct 1170 ms 2080 KB Output is correct
38 Correct 1202 ms 2080 KB Output is correct
39 Correct 1161 ms 2076 KB Output is correct
40 Execution timed out 1588 ms 2244 KB Time limit exceeded
41 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 2 ms 204 KB Output is correct
14 Correct 2 ms 204 KB Output is correct
15 Correct 2 ms 204 KB Output is correct
16 Correct 2 ms 332 KB Output is correct
17 Correct 2 ms 332 KB Output is correct
18 Correct 2 ms 332 KB Output is correct
19 Correct 2 ms 204 KB Output is correct
20 Correct 3 ms 204 KB Output is correct
21 Correct 2 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 1 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 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 2 ms 204 KB Output is correct
34 Correct 2 ms 204 KB Output is correct
35 Correct 1 ms 204 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 1 ms 204 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Correct 1 ms 204 KB Output is correct
41 Correct 1 ms 204 KB Output is correct
42 Correct 1 ms 204 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Correct 1 ms 204 KB Output is correct
45 Correct 1 ms 204 KB Output is correct
46 Correct 2 ms 204 KB Output is correct
47 Correct 1 ms 204 KB Output is correct
48 Correct 1 ms 204 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
50 Correct 2 ms 204 KB Output is correct
51 Correct 2 ms 332 KB Output is correct
52 Correct 2 ms 332 KB Output is correct
53 Correct 2 ms 332 KB Output is correct
54 Correct 2 ms 204 KB Output is correct
55 Correct 2 ms 332 KB Output is correct
56 Correct 2 ms 204 KB Output is correct
57 Correct 2 ms 332 KB Output is correct
58 Correct 2 ms 204 KB Output is correct
59 Correct 2 ms 204 KB Output is correct
60 Correct 2 ms 204 KB Output is correct
61 Correct 2 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 2 ms 204 KB Output is correct
16 Correct 2 ms 204 KB Output is correct
17 Correct 2 ms 204 KB Output is correct
18 Correct 2 ms 332 KB Output is correct
19 Correct 2 ms 332 KB Output is correct
20 Correct 2 ms 332 KB Output is correct
21 Correct 2 ms 204 KB Output is correct
22 Correct 3 ms 204 KB Output is correct
23 Correct 2 ms 204 KB Output is correct
24 Correct 20 ms 972 KB Output is correct
25 Correct 17 ms 1096 KB Output is correct
26 Correct 16 ms 1100 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 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 204 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 1 ms 204 KB Output is correct
36 Correct 2 ms 204 KB Output is correct
37 Correct 2 ms 204 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Correct 1 ms 204 KB Output is correct
41 Correct 1 ms 204 KB Output is correct
42 Correct 1 ms 204 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Correct 1 ms 204 KB Output is correct
45 Correct 1 ms 204 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 1 ms 204 KB Output is correct
48 Correct 1 ms 204 KB Output is correct
49 Correct 2 ms 204 KB Output is correct
50 Correct 1 ms 204 KB Output is correct
51 Correct 1 ms 204 KB Output is correct
52 Correct 1 ms 204 KB Output is correct
53 Correct 2 ms 204 KB Output is correct
54 Correct 2 ms 332 KB Output is correct
55 Correct 2 ms 332 KB Output is correct
56 Correct 2 ms 332 KB Output is correct
57 Correct 2 ms 204 KB Output is correct
58 Correct 2 ms 332 KB Output is correct
59 Correct 2 ms 204 KB Output is correct
60 Correct 2 ms 332 KB Output is correct
61 Correct 2 ms 204 KB Output is correct
62 Correct 2 ms 204 KB Output is correct
63 Correct 2 ms 204 KB Output is correct
64 Correct 2 ms 204 KB Output is correct
65 Correct 1 ms 204 KB Output is correct
66 Correct 1 ms 204 KB Output is correct
67 Correct 1 ms 204 KB Output is correct
68 Correct 1 ms 204 KB Output is correct
69 Correct 2 ms 204 KB Output is correct
70 Correct 10 ms 396 KB Output is correct
71 Correct 7 ms 408 KB Output is correct
72 Correct 4 ms 392 KB Output is correct
73 Correct 2 ms 332 KB Output is correct
74 Correct 4 ms 332 KB Output is correct
75 Correct 6 ms 384 KB Output is correct
76 Correct 16 ms 1144 KB Output is correct
77 Correct 16 ms 1180 KB Output is correct
78 Correct 19 ms 1356 KB Output is correct
79 Correct 1 ms 332 KB Output is correct
80 Correct 2 ms 332 KB Output is correct
81 Correct 2 ms 332 KB Output is correct
82 Correct 2 ms 332 KB Output is correct
83 Correct 2 ms 336 KB Output is correct
84 Correct 9 ms 460 KB Output is correct
85 Correct 12 ms 512 KB Output is correct
86 Correct 10 ms 524 KB Output is correct
87 Correct 8 ms 460 KB Output is correct
88 Correct 8 ms 460 KB Output is correct
89 Correct 9 ms 460 KB Output is correct
90 Correct 24 ms 2380 KB Output is correct
91 Correct 24 ms 2380 KB Output is correct
92 Correct 24 ms 2364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 2 ms 204 KB Output is correct
16 Correct 2 ms 204 KB Output is correct
17 Correct 2 ms 204 KB Output is correct
18 Correct 2 ms 332 KB Output is correct
19 Correct 2 ms 332 KB Output is correct
20 Correct 2 ms 332 KB Output is correct
21 Correct 2 ms 204 KB Output is correct
22 Correct 3 ms 204 KB Output is correct
23 Correct 2 ms 204 KB Output is correct
24 Correct 20 ms 972 KB Output is correct
25 Correct 17 ms 1096 KB Output is correct
26 Correct 16 ms 1100 KB Output is correct
27 Correct 227 ms 844 KB Output is correct
28 Correct 214 ms 848 KB Output is correct
29 Correct 4 ms 588 KB Output is correct
30 Correct 4 ms 460 KB Output is correct
31 Correct 4 ms 332 KB Output is correct
32 Correct 4 ms 332 KB Output is correct
33 Correct 1253 ms 1240 KB Output is correct
34 Correct 1227 ms 1348 KB Output is correct
35 Correct 1234 ms 1464 KB Output is correct
36 Correct 1285 ms 1480 KB Output is correct
37 Correct 1243 ms 1372 KB Output is correct
38 Correct 1226 ms 1360 KB Output is correct
39 Correct 1170 ms 2080 KB Output is correct
40 Correct 1202 ms 2080 KB Output is correct
41 Correct 1161 ms 2076 KB Output is correct
42 Correct 1 ms 204 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Correct 1 ms 204 KB Output is correct
45 Correct 1 ms 204 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 1 ms 204 KB Output is correct
48 Correct 1 ms 204 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
50 Correct 1 ms 204 KB Output is correct
51 Correct 2 ms 204 KB Output is correct
52 Correct 2 ms 204 KB Output is correct
53 Correct 1 ms 204 KB Output is correct
54 Correct 1 ms 204 KB Output is correct
55 Correct 1 ms 204 KB Output is correct
56 Correct 1 ms 204 KB Output is correct
57 Correct 1 ms 204 KB Output is correct
58 Correct 1 ms 204 KB Output is correct
59 Correct 1 ms 204 KB Output is correct
60 Correct 1 ms 204 KB Output is correct
61 Correct 1 ms 204 KB Output is correct
62 Correct 1 ms 204 KB Output is correct
63 Correct 1 ms 204 KB Output is correct
64 Correct 2 ms 204 KB Output is correct
65 Correct 1 ms 204 KB Output is correct
66 Correct 1 ms 204 KB Output is correct
67 Correct 1 ms 204 KB Output is correct
68 Correct 2 ms 204 KB Output is correct
69 Correct 2 ms 332 KB Output is correct
70 Correct 2 ms 332 KB Output is correct
71 Correct 2 ms 332 KB Output is correct
72 Correct 2 ms 204 KB Output is correct
73 Correct 2 ms 332 KB Output is correct
74 Correct 2 ms 204 KB Output is correct
75 Correct 2 ms 332 KB Output is correct
76 Correct 2 ms 204 KB Output is correct
77 Correct 2 ms 204 KB Output is correct
78 Correct 2 ms 204 KB Output is correct
79 Correct 2 ms 204 KB Output is correct
80 Correct 1 ms 204 KB Output is correct
81 Correct 1 ms 204 KB Output is correct
82 Correct 1 ms 204 KB Output is correct
83 Correct 1 ms 204 KB Output is correct
84 Correct 2 ms 204 KB Output is correct
85 Correct 10 ms 396 KB Output is correct
86 Correct 7 ms 408 KB Output is correct
87 Correct 4 ms 392 KB Output is correct
88 Correct 2 ms 332 KB Output is correct
89 Correct 4 ms 332 KB Output is correct
90 Correct 6 ms 384 KB Output is correct
91 Correct 16 ms 1144 KB Output is correct
92 Correct 16 ms 1180 KB Output is correct
93 Correct 19 ms 1356 KB Output is correct
94 Correct 1 ms 332 KB Output is correct
95 Correct 2 ms 332 KB Output is correct
96 Correct 2 ms 332 KB Output is correct
97 Correct 2 ms 332 KB Output is correct
98 Correct 2 ms 336 KB Output is correct
99 Correct 9 ms 460 KB Output is correct
100 Correct 12 ms 512 KB Output is correct
101 Correct 10 ms 524 KB Output is correct
102 Correct 8 ms 460 KB Output is correct
103 Correct 8 ms 460 KB Output is correct
104 Correct 9 ms 460 KB Output is correct
105 Correct 24 ms 2380 KB Output is correct
106 Correct 24 ms 2380 KB Output is correct
107 Correct 24 ms 2364 KB Output is correct
108 Correct 193 ms 844 KB Output is correct
109 Correct 144 ms 700 KB Output is correct
110 Correct 232 ms 460 KB Output is correct
111 Correct 203 ms 472 KB Output is correct
112 Correct 257 ms 516 KB Output is correct
113 Correct 180 ms 500 KB Output is correct
114 Correct 1027 ms 1504 KB Output is correct
115 Correct 136 ms 1492 KB Output is correct
116 Correct 1166 ms 1964 KB Output is correct
117 Correct 803 ms 1548 KB Output is correct
118 Correct 196 ms 1532 KB Output is correct
119 Correct 1392 ms 1504 KB Output is correct
120 Correct 616 ms 1820 KB Output is correct
121 Correct 557 ms 916 KB Output is correct
122 Correct 327 ms 2116 KB Output is correct
123 Correct 240 ms 856 KB Output is correct
124 Correct 205 ms 2252 KB Output is correct
125 Correct 295 ms 1168 KB Output is correct
126 Correct 38 ms 844 KB Output is correct
127 Correct 494 ms 976 KB Output is correct
128 Correct 120 ms 752 KB Output is correct
129 Correct 167 ms 776 KB Output is correct
130 Correct 198 ms 844 KB Output is correct
131 Correct 269 ms 888 KB Output is correct
132 Correct 384 ms 588 KB Output is correct
133 Correct 385 ms 640 KB Output is correct
134 Correct 396 ms 588 KB Output is correct
135 Correct 385 ms 588 KB Output is correct
136 Execution timed out 1579 ms 2052 KB Time limit exceeded
137 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 2 ms 204 KB Output is correct
16 Correct 2 ms 204 KB Output is correct
17 Correct 2 ms 204 KB Output is correct
18 Correct 2 ms 332 KB Output is correct
19 Correct 2 ms 332 KB Output is correct
20 Correct 2 ms 332 KB Output is correct
21 Correct 2 ms 204 KB Output is correct
22 Correct 3 ms 204 KB Output is correct
23 Correct 2 ms 204 KB Output is correct
24 Correct 20 ms 972 KB Output is correct
25 Correct 17 ms 1096 KB Output is correct
26 Correct 16 ms 1100 KB Output is correct
27 Correct 227 ms 844 KB Output is correct
28 Correct 214 ms 848 KB Output is correct
29 Correct 4 ms 588 KB Output is correct
30 Correct 4 ms 460 KB Output is correct
31 Correct 4 ms 332 KB Output is correct
32 Correct 4 ms 332 KB Output is correct
33 Correct 1253 ms 1240 KB Output is correct
34 Correct 1227 ms 1348 KB Output is correct
35 Correct 1234 ms 1464 KB Output is correct
36 Correct 1285 ms 1480 KB Output is correct
37 Correct 1243 ms 1372 KB Output is correct
38 Correct 1226 ms 1360 KB Output is correct
39 Correct 1170 ms 2080 KB Output is correct
40 Correct 1202 ms 2080 KB Output is correct
41 Correct 1161 ms 2076 KB Output is correct
42 Execution timed out 1588 ms 2244 KB Time limit exceeded
43 Halted 0 ms 0 KB -