답안 #965720

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
965720 2024-04-19T06:06:57 Z Pring 벽 칠하기 (APIO20_paint) C++17
28 / 100
1500 ms 9816 KB
#include <bits/stdc++.h>
#include "paint.h"
using namespace std;

#ifdef MIKU
string dbmc = "\033[1;38;2;57;197;187m", dbrs = "\033[0m";
#define debug(x...) cout << dbmc << "[" << #x << "]: ", dout(x)
void dout() { cout << dbrs << endl; }
template <typename T, typename ...U>
void dout(T t, U ...u) { cout << t << (sizeof...(u) ? ", " : ""); dout(u...); }
#else
#define debug(...) 39
#endif

#define fs first
#define sc second
#define mp make_pair
#define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++)
using ll = long long;
typedef pair<int, int> pii;

namespace {
    const int MXN = 200005, INF = 1e9;
    int n, m, k;
    vector<int> c;
    vector<vector<int>> clr;

    int cid[MXN], worker[MXN];
    bitset<MXN> b;
    int dp[MXN];

    bool calc(int sr) {
        auto check = [&](int x) -> bool {
            FOR(i, 0, m) {
                auto it = lower_bound(clr[(x + i) % m].begin(), clr[(x + i) % m].end(), c[sr + i]);
                if (it == clr[(x + i) % m].end()) return false;
                if (*it != c[sr + i]) return false;
            }
            return true;
        };
        FOR(x, 0, m) if (check(x)) return true;
        return false;
    }

    int miku() {
        FOR(i, m, n + 1) b[i] = calc(i - m);
        deque<pii> dq;
        dq.push_back(mp(0, 0));
        FOR(i, 1, n + 1) {
            if (!b[i]) dp[i] = INF;
            else {
                while (dq.front().sc < i - m) dq.pop_front();
                dp[i] = dq.front().fs + 1;
            }
            while (dq.size() && dq.back().fs >= dp[i]) dq.pop_back();
            dq.push_back(mp(dp[i], i));
        }
        return (dp[n] >= INF ? -1 : dp[n]);
    }
}

int minimumInstructions(int N, int M, int K, vector<int> C, vector<int> A, vector<vector<int>> B) {
    ::n = N;
    ::m = M;
    ::k = K;
    ::c = C;
    ::clr = B;
    return miku();
}

Compilation message

paint.cpp:28:19: warning: '{anonymous}::worker' defined but not used [-Wunused-variable]
   28 |     int cid[MXN], worker[MXN];
      |                   ^~~~~~
paint.cpp:28:9: warning: '{anonymous}::cid' defined but not used [-Wunused-variable]
   28 |     int cid[MXN], worker[MXN];
      |         ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 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 1 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 0 ms 600 KB Output is correct
10 Correct 1 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 348 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 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 488 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 11 ms 1612 KB Output is correct
23 Correct 13 ms 1628 KB Output is correct
24 Correct 10 ms 1468 KB Output is correct
25 Correct 3 ms 604 KB Output is correct
26 Correct 3 ms 752 KB Output is correct
27 Correct 2 ms 604 KB Output is correct
28 Correct 3 ms 604 KB Output is correct
29 Correct 2 ms 604 KB Output is correct
30 Correct 3 ms 856 KB Output is correct
31 Correct 645 ms 1120 KB Output is correct
32 Correct 655 ms 1116 KB Output is correct
33 Correct 628 ms 1116 KB Output is correct
34 Correct 619 ms 1096 KB Output is correct
35 Correct 632 ms 1116 KB Output is correct
36 Correct 628 ms 1116 KB Output is correct
37 Correct 921 ms 2324 KB Output is correct
38 Correct 928 ms 2080 KB Output is correct
39 Correct 925 ms 2072 KB Output is correct
40 Correct 7 ms 1884 KB Output is correct
41 Correct 5 ms 1188 KB Output is correct
42 Correct 10 ms 1884 KB Output is correct
43 Correct 7 ms 1368 KB Output is correct
44 Correct 7 ms 1372 KB Output is correct
45 Correct 11 ms 1900 KB Output is correct
46 Execution timed out 1595 ms 9816 KB Time limit exceeded
47 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 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 1 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 0 ms 600 KB Output is correct
10 Correct 1 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 348 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 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 488 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 504 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 596 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 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 344 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 344 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 448 KB Output is correct
42 Correct 1 ms 348 KB Output is correct
43 Correct 1 ms 444 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 1 ms 344 KB Output is correct
46 Correct 1 ms 448 KB Output is correct
47 Correct 1 ms 344 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 348 KB Output is correct
51 Correct 1 ms 600 KB Output is correct
52 Correct 1 ms 348 KB Output is correct
53 Correct 1 ms 348 KB Output is correct
54 Correct 1 ms 348 KB Output is correct
55 Correct 1 ms 428 KB Output is correct
56 Correct 1 ms 348 KB Output is correct
57 Correct 2 ms 348 KB Output is correct
58 Correct 1 ms 348 KB Output is correct
59 Correct 1 ms 348 KB Output is correct
60 Correct 1 ms 344 KB Output is correct
61 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 1 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 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 0 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 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 2 ms 348 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 1 ms 348 KB Output is correct
22 Correct 1 ms 488 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 11 ms 1612 KB Output is correct
25 Correct 13 ms 1628 KB Output is correct
26 Correct 10 ms 1468 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 1 ms 504 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 596 KB Output is correct
34 Correct 1 ms 344 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 344 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 1 ms 344 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 448 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 1 ms 444 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 1 ms 344 KB Output is correct
49 Correct 1 ms 448 KB Output is correct
50 Correct 1 ms 344 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 348 KB Output is correct
54 Correct 1 ms 600 KB Output is correct
55 Correct 1 ms 348 KB Output is correct
56 Correct 1 ms 348 KB Output is correct
57 Correct 1 ms 348 KB Output is correct
58 Correct 1 ms 428 KB Output is correct
59 Correct 1 ms 348 KB Output is correct
60 Correct 2 ms 348 KB Output is correct
61 Correct 1 ms 348 KB Output is correct
62 Correct 1 ms 348 KB Output is correct
63 Correct 1 ms 344 KB Output is correct
64 Correct 1 ms 348 KB Output is correct
65 Correct 1 ms 448 KB Output is correct
66 Correct 0 ms 348 KB Output is correct
67 Correct 1 ms 348 KB Output is correct
68 Correct 1 ms 348 KB Output is correct
69 Correct 1 ms 348 KB Output is correct
70 Correct 7 ms 604 KB Output is correct
71 Correct 3 ms 604 KB Output is correct
72 Correct 2 ms 524 KB Output is correct
73 Correct 1 ms 348 KB Output is correct
74 Correct 2 ms 456 KB Output is correct
75 Correct 3 ms 496 KB Output is correct
76 Correct 9 ms 2140 KB Output is correct
77 Correct 10 ms 2396 KB Output is correct
78 Correct 11 ms 2908 KB Output is correct
79 Correct 1 ms 348 KB Output is correct
80 Correct 1 ms 348 KB Output is correct
81 Correct 1 ms 348 KB Output is correct
82 Correct 1 ms 348 KB Output is correct
83 Correct 1 ms 348 KB Output is correct
84 Correct 4 ms 604 KB Output is correct
85 Correct 8 ms 600 KB Output is correct
86 Correct 5 ms 600 KB Output is correct
87 Correct 4 ms 604 KB Output is correct
88 Correct 4 ms 604 KB Output is correct
89 Correct 5 ms 724 KB Output is correct
90 Correct 14 ms 2912 KB Output is correct
91 Correct 14 ms 2908 KB Output is correct
92 Correct 14 ms 2908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 1 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 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 0 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 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 2 ms 348 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 1 ms 348 KB Output is correct
22 Correct 1 ms 488 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 11 ms 1612 KB Output is correct
25 Correct 13 ms 1628 KB Output is correct
26 Correct 10 ms 1468 KB Output is correct
27 Correct 3 ms 604 KB Output is correct
28 Correct 3 ms 752 KB Output is correct
29 Correct 2 ms 604 KB Output is correct
30 Correct 3 ms 604 KB Output is correct
31 Correct 2 ms 604 KB Output is correct
32 Correct 3 ms 856 KB Output is correct
33 Correct 645 ms 1120 KB Output is correct
34 Correct 655 ms 1116 KB Output is correct
35 Correct 628 ms 1116 KB Output is correct
36 Correct 619 ms 1096 KB Output is correct
37 Correct 632 ms 1116 KB Output is correct
38 Correct 628 ms 1116 KB Output is correct
39 Correct 921 ms 2324 KB Output is correct
40 Correct 928 ms 2080 KB Output is correct
41 Correct 925 ms 2072 KB Output is correct
42 Correct 1 ms 348 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 1 ms 344 KB Output is correct
46 Correct 1 ms 504 KB Output is correct
47 Correct 1 ms 348 KB Output is correct
48 Correct 1 ms 596 KB Output is correct
49 Correct 1 ms 344 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 344 KB Output is correct
54 Correct 1 ms 348 KB Output is correct
55 Correct 1 ms 344 KB Output is correct
56 Correct 1 ms 348 KB Output is correct
57 Correct 0 ms 348 KB Output is correct
58 Correct 1 ms 348 KB Output is correct
59 Correct 1 ms 448 KB Output is correct
60 Correct 1 ms 348 KB Output is correct
61 Correct 1 ms 444 KB Output is correct
62 Correct 0 ms 348 KB Output is correct
63 Correct 1 ms 344 KB Output is correct
64 Correct 1 ms 448 KB Output is correct
65 Correct 1 ms 344 KB Output is correct
66 Correct 1 ms 348 KB Output is correct
67 Correct 1 ms 348 KB Output is correct
68 Correct 1 ms 348 KB Output is correct
69 Correct 1 ms 600 KB Output is correct
70 Correct 1 ms 348 KB Output is correct
71 Correct 1 ms 348 KB Output is correct
72 Correct 1 ms 348 KB Output is correct
73 Correct 1 ms 428 KB Output is correct
74 Correct 1 ms 348 KB Output is correct
75 Correct 2 ms 348 KB Output is correct
76 Correct 1 ms 348 KB Output is correct
77 Correct 1 ms 348 KB Output is correct
78 Correct 1 ms 344 KB Output is correct
79 Correct 1 ms 348 KB Output is correct
80 Correct 1 ms 448 KB Output is correct
81 Correct 0 ms 348 KB Output is correct
82 Correct 1 ms 348 KB Output is correct
83 Correct 1 ms 348 KB Output is correct
84 Correct 1 ms 348 KB Output is correct
85 Correct 7 ms 604 KB Output is correct
86 Correct 3 ms 604 KB Output is correct
87 Correct 2 ms 524 KB Output is correct
88 Correct 1 ms 348 KB Output is correct
89 Correct 2 ms 456 KB Output is correct
90 Correct 3 ms 496 KB Output is correct
91 Correct 9 ms 2140 KB Output is correct
92 Correct 10 ms 2396 KB Output is correct
93 Correct 11 ms 2908 KB Output is correct
94 Correct 1 ms 348 KB Output is correct
95 Correct 1 ms 348 KB Output is correct
96 Correct 1 ms 348 KB Output is correct
97 Correct 1 ms 348 KB Output is correct
98 Correct 1 ms 348 KB Output is correct
99 Correct 4 ms 604 KB Output is correct
100 Correct 8 ms 600 KB Output is correct
101 Correct 5 ms 600 KB Output is correct
102 Correct 4 ms 604 KB Output is correct
103 Correct 4 ms 604 KB Output is correct
104 Correct 5 ms 724 KB Output is correct
105 Correct 14 ms 2912 KB Output is correct
106 Correct 14 ms 2908 KB Output is correct
107 Correct 14 ms 2908 KB Output is correct
108 Correct 2 ms 608 KB Output is correct
109 Correct 39 ms 744 KB Output is correct
110 Correct 188 ms 716 KB Output is correct
111 Correct 148 ms 720 KB Output is correct
112 Correct 207 ms 612 KB Output is correct
113 Correct 141 ms 756 KB Output is correct
114 Correct 692 ms 1640 KB Output is correct
115 Correct 52 ms 1880 KB Output is correct
116 Correct 625 ms 2116 KB Output is correct
117 Correct 528 ms 1880 KB Output is correct
118 Correct 69 ms 1752 KB Output is correct
119 Correct 943 ms 1624 KB Output is correct
120 Correct 484 ms 2444 KB Output is correct
121 Correct 270 ms 860 KB Output is correct
122 Correct 228 ms 2896 KB Output is correct
123 Correct 116 ms 860 KB Output is correct
124 Correct 147 ms 2968 KB Output is correct
125 Correct 86 ms 1104 KB Output is correct
126 Correct 24 ms 1364 KB Output is correct
127 Correct 333 ms 1364 KB Output is correct
128 Correct 81 ms 1036 KB Output is correct
129 Correct 114 ms 1068 KB Output is correct
130 Correct 2 ms 604 KB Output is correct
131 Correct 57 ms 1084 KB Output is correct
132 Correct 291 ms 852 KB Output is correct
133 Correct 286 ms 860 KB Output is correct
134 Correct 293 ms 892 KB Output is correct
135 Correct 295 ms 856 KB Output is correct
136 Execution timed out 1504 ms 2432 KB Time limit exceeded
137 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 1 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 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 0 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 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 2 ms 348 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 1 ms 348 KB Output is correct
22 Correct 1 ms 488 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 11 ms 1612 KB Output is correct
25 Correct 13 ms 1628 KB Output is correct
26 Correct 10 ms 1468 KB Output is correct
27 Correct 3 ms 604 KB Output is correct
28 Correct 3 ms 752 KB Output is correct
29 Correct 2 ms 604 KB Output is correct
30 Correct 3 ms 604 KB Output is correct
31 Correct 2 ms 604 KB Output is correct
32 Correct 3 ms 856 KB Output is correct
33 Correct 645 ms 1120 KB Output is correct
34 Correct 655 ms 1116 KB Output is correct
35 Correct 628 ms 1116 KB Output is correct
36 Correct 619 ms 1096 KB Output is correct
37 Correct 632 ms 1116 KB Output is correct
38 Correct 628 ms 1116 KB Output is correct
39 Correct 921 ms 2324 KB Output is correct
40 Correct 928 ms 2080 KB Output is correct
41 Correct 925 ms 2072 KB Output is correct
42 Correct 7 ms 1884 KB Output is correct
43 Correct 5 ms 1188 KB Output is correct
44 Correct 10 ms 1884 KB Output is correct
45 Correct 7 ms 1368 KB Output is correct
46 Correct 7 ms 1372 KB Output is correct
47 Correct 11 ms 1900 KB Output is correct
48 Execution timed out 1595 ms 9816 KB Time limit exceeded
49 Halted 0 ms 0 KB -