답안 #1054463

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1054463 2024-08-12T10:03:20 Z alexander707070 벽 칠하기 (APIO20_paint) C++14
51 / 100
1500 ms 23120 KB
#include<bits/stdc++.h>
#include "paint.h"

#define MAXN 100007
using namespace std;

int n,m,k,ans;
int c[MAXN];
unordered_set<int> cols[MAXN];

bool can[MAXN];
int to[2][MAXN];
int best[MAXN],pref[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=1;i<=n;i++){
        c[i]=C[i-1];
    }

    for(int i=1;i<=m;i++){
        for(int s:B[i-1])cols[i].insert(s);
    }

    for(int i=n;i>=1;i--){
        for(int f=1;f<=m;f++){
            if(cols[f].find(c[i])!=cols[f].end())can[f]=true;
            else can[f]=false;

            if(!can[f])to[i%2][f]=0;
            else{
                if(f<m)to[i%2][f]=to[1-i%2][f+1]+1;
                else to[i%2][f]=to[1-i%2][1]+1;
            }

            if(to[i%2][f]>=m)best[i]=max(best[i],i+m);
        }
    }

    for(int i=1;i<=n;i++){
        pref[i]=max(pref[i-1],best[i]);
    }

    int pos=1;
    while(pos<=n){
        if(pref[pos]<=pos)return -1;

        pos=pref[pos];
        ans++;
    }

    return ans;
}

/*
int main(){
    //cout<<minimumInstructions(8, 3, 5, {3, 3, 1, 3, 4, 4, 2, 2}, {3, 2, 2}, {{0, 1, 2}, {2, 3}, {3, 4}});
    cout<<minimumInstructions(5, 4, 4, {1, 0, 1, 2, 2}, {2, 1, 1, 1}, {{0, 1}, {1}, {2}, {3}});


    return 0;
}
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 7260 KB Output is correct
2 Correct 1 ms 7300 KB Output is correct
3 Correct 2 ms 7260 KB Output is correct
4 Correct 2 ms 7260 KB Output is correct
5 Correct 1 ms 7260 KB Output is correct
6 Correct 1 ms 7260 KB Output is correct
7 Correct 1 ms 7260 KB Output is correct
8 Correct 1 ms 7260 KB Output is correct
9 Correct 1 ms 7260 KB Output is correct
10 Correct 1 ms 7260 KB Output is correct
11 Correct 1 ms 7260 KB Output is correct
12 Correct 1 ms 7260 KB Output is correct
13 Correct 2 ms 7348 KB Output is correct
14 Correct 2 ms 7260 KB Output is correct
15 Correct 1 ms 7260 KB Output is correct
16 Correct 2 ms 7260 KB Output is correct
17 Correct 2 ms 7260 KB Output is correct
18 Correct 2 ms 7256 KB Output is correct
19 Correct 2 ms 7260 KB Output is correct
20 Correct 2 ms 7260 KB Output is correct
21 Correct 2 ms 7260 KB Output is correct
22 Correct 13 ms 11996 KB Output is correct
23 Correct 13 ms 12124 KB Output is correct
24 Correct 13 ms 12120 KB Output is correct
25 Correct 2 ms 7516 KB Output is correct
26 Correct 3 ms 7516 KB Output is correct
27 Correct 2 ms 7516 KB Output is correct
28 Correct 2 ms 7516 KB Output is correct
29 Correct 2 ms 7516 KB Output is correct
30 Correct 2 ms 7516 KB Output is correct
31 Correct 396 ms 8776 KB Output is correct
32 Correct 385 ms 8788 KB Output is correct
33 Correct 376 ms 8760 KB Output is correct
34 Correct 408 ms 8772 KB Output is correct
35 Correct 378 ms 8768 KB Output is correct
36 Correct 373 ms 8768 KB Output is correct
37 Correct 672 ms 12752 KB Output is correct
38 Correct 654 ms 12636 KB Output is correct
39 Correct 664 ms 12632 KB Output is correct
40 Correct 5 ms 8540 KB Output is correct
41 Correct 4 ms 8268 KB Output is correct
42 Correct 7 ms 9044 KB Output is correct
43 Correct 5 ms 8284 KB Output is correct
44 Correct 5 ms 8284 KB Output is correct
45 Correct 7 ms 8796 KB Output is correct
46 Execution timed out 1542 ms 23120 KB Time limit exceeded
47 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 7260 KB Output is correct
2 Correct 1 ms 7300 KB Output is correct
3 Correct 2 ms 7260 KB Output is correct
4 Correct 2 ms 7260 KB Output is correct
5 Correct 1 ms 7260 KB Output is correct
6 Correct 1 ms 7260 KB Output is correct
7 Correct 1 ms 7260 KB Output is correct
8 Correct 1 ms 7260 KB Output is correct
9 Correct 1 ms 7260 KB Output is correct
10 Correct 1 ms 7260 KB Output is correct
11 Correct 1 ms 7260 KB Output is correct
12 Correct 1 ms 7260 KB Output is correct
13 Correct 2 ms 7348 KB Output is correct
14 Correct 2 ms 7260 KB Output is correct
15 Correct 1 ms 7260 KB Output is correct
16 Correct 2 ms 7260 KB Output is correct
17 Correct 2 ms 7260 KB Output is correct
18 Correct 2 ms 7256 KB Output is correct
19 Correct 2 ms 7260 KB Output is correct
20 Correct 2 ms 7260 KB Output is correct
21 Correct 2 ms 7260 KB Output is correct
22 Correct 2 ms 7256 KB Output is correct
23 Correct 1 ms 7260 KB Output is correct
24 Correct 1 ms 7260 KB Output is correct
25 Correct 1 ms 7260 KB Output is correct
26 Correct 1 ms 7260 KB Output is correct
27 Correct 1 ms 7260 KB Output is correct
28 Correct 1 ms 7352 KB Output is correct
29 Correct 1 ms 7260 KB Output is correct
30 Correct 1 ms 7260 KB Output is correct
31 Correct 1 ms 7260 KB Output is correct
32 Correct 1 ms 7260 KB Output is correct
33 Correct 1 ms 7260 KB Output is correct
34 Correct 1 ms 7260 KB Output is correct
35 Correct 1 ms 7260 KB Output is correct
36 Correct 2 ms 7352 KB Output is correct
37 Correct 1 ms 7260 KB Output is correct
38 Correct 1 ms 7260 KB Output is correct
39 Correct 1 ms 7260 KB Output is correct
40 Correct 1 ms 7260 KB Output is correct
41 Correct 1 ms 7344 KB Output is correct
42 Correct 1 ms 7260 KB Output is correct
43 Correct 1 ms 7260 KB Output is correct
44 Correct 1 ms 7260 KB Output is correct
45 Correct 1 ms 7260 KB Output is correct
46 Correct 1 ms 7260 KB Output is correct
47 Correct 1 ms 7260 KB Output is correct
48 Correct 2 ms 7260 KB Output is correct
49 Correct 1 ms 7260 KB Output is correct
50 Correct 2 ms 7260 KB Output is correct
51 Correct 2 ms 7260 KB Output is correct
52 Correct 1 ms 7260 KB Output is correct
53 Correct 2 ms 7260 KB Output is correct
54 Correct 2 ms 7260 KB Output is correct
55 Correct 2 ms 7260 KB Output is correct
56 Correct 2 ms 7260 KB Output is correct
57 Correct 2 ms 7260 KB Output is correct
58 Correct 2 ms 7260 KB Output is correct
59 Correct 2 ms 7260 KB Output is correct
60 Correct 2 ms 7260 KB Output is correct
61 Correct 2 ms 7260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 7256 KB Output is correct
2 Correct 1 ms 7260 KB Output is correct
3 Correct 2 ms 7260 KB Output is correct
4 Correct 1 ms 7300 KB Output is correct
5 Correct 2 ms 7260 KB Output is correct
6 Correct 2 ms 7260 KB Output is correct
7 Correct 1 ms 7260 KB Output is correct
8 Correct 1 ms 7260 KB Output is correct
9 Correct 1 ms 7260 KB Output is correct
10 Correct 1 ms 7260 KB Output is correct
11 Correct 1 ms 7260 KB Output is correct
12 Correct 1 ms 7260 KB Output is correct
13 Correct 1 ms 7260 KB Output is correct
14 Correct 1 ms 7260 KB Output is correct
15 Correct 2 ms 7348 KB Output is correct
16 Correct 2 ms 7260 KB Output is correct
17 Correct 1 ms 7260 KB Output is correct
18 Correct 2 ms 7260 KB Output is correct
19 Correct 2 ms 7260 KB Output is correct
20 Correct 2 ms 7256 KB Output is correct
21 Correct 2 ms 7260 KB Output is correct
22 Correct 2 ms 7260 KB Output is correct
23 Correct 2 ms 7260 KB Output is correct
24 Correct 13 ms 11996 KB Output is correct
25 Correct 13 ms 12124 KB Output is correct
26 Correct 13 ms 12120 KB Output is correct
27 Correct 1 ms 7260 KB Output is correct
28 Correct 1 ms 7260 KB Output is correct
29 Correct 1 ms 7260 KB Output is correct
30 Correct 1 ms 7260 KB Output is correct
31 Correct 1 ms 7352 KB Output is correct
32 Correct 1 ms 7260 KB Output is correct
33 Correct 1 ms 7260 KB Output is correct
34 Correct 1 ms 7260 KB Output is correct
35 Correct 1 ms 7260 KB Output is correct
36 Correct 1 ms 7260 KB Output is correct
37 Correct 1 ms 7260 KB Output is correct
38 Correct 1 ms 7260 KB Output is correct
39 Correct 2 ms 7352 KB Output is correct
40 Correct 1 ms 7260 KB Output is correct
41 Correct 1 ms 7260 KB Output is correct
42 Correct 1 ms 7260 KB Output is correct
43 Correct 1 ms 7260 KB Output is correct
44 Correct 1 ms 7344 KB Output is correct
45 Correct 1 ms 7260 KB Output is correct
46 Correct 1 ms 7260 KB Output is correct
47 Correct 1 ms 7260 KB Output is correct
48 Correct 1 ms 7260 KB Output is correct
49 Correct 1 ms 7260 KB Output is correct
50 Correct 1 ms 7260 KB Output is correct
51 Correct 2 ms 7260 KB Output is correct
52 Correct 1 ms 7260 KB Output is correct
53 Correct 2 ms 7260 KB Output is correct
54 Correct 2 ms 7260 KB Output is correct
55 Correct 1 ms 7260 KB Output is correct
56 Correct 2 ms 7260 KB Output is correct
57 Correct 2 ms 7260 KB Output is correct
58 Correct 2 ms 7260 KB Output is correct
59 Correct 2 ms 7260 KB Output is correct
60 Correct 2 ms 7260 KB Output is correct
61 Correct 2 ms 7260 KB Output is correct
62 Correct 2 ms 7260 KB Output is correct
63 Correct 2 ms 7260 KB Output is correct
64 Correct 2 ms 7260 KB Output is correct
65 Correct 2 ms 7260 KB Output is correct
66 Correct 1 ms 7260 KB Output is correct
67 Correct 1 ms 7260 KB Output is correct
68 Correct 1 ms 7260 KB Output is correct
69 Correct 1 ms 7256 KB Output is correct
70 Correct 3 ms 7772 KB Output is correct
71 Correct 3 ms 8024 KB Output is correct
72 Correct 3 ms 7772 KB Output is correct
73 Correct 2 ms 7512 KB Output is correct
74 Correct 3 ms 7772 KB Output is correct
75 Correct 3 ms 7772 KB Output is correct
76 Correct 14 ms 12632 KB Output is correct
77 Correct 14 ms 13240 KB Output is correct
78 Correct 16 ms 14200 KB Output is correct
79 Correct 2 ms 7260 KB Output is correct
80 Correct 1 ms 7260 KB Output is correct
81 Correct 1 ms 7260 KB Output is correct
82 Correct 2 ms 7260 KB Output is correct
83 Correct 2 ms 7260 KB Output is correct
84 Correct 4 ms 8028 KB Output is correct
85 Correct 5 ms 8028 KB Output is correct
86 Correct 4 ms 8108 KB Output is correct
87 Correct 4 ms 8028 KB Output is correct
88 Correct 4 ms 8028 KB Output is correct
89 Correct 4 ms 8028 KB Output is correct
90 Correct 20 ms 15288 KB Output is correct
91 Correct 21 ms 15244 KB Output is correct
92 Correct 22 ms 15196 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 7256 KB Output is correct
2 Correct 1 ms 7260 KB Output is correct
3 Correct 2 ms 7260 KB Output is correct
4 Correct 1 ms 7300 KB Output is correct
5 Correct 2 ms 7260 KB Output is correct
6 Correct 2 ms 7260 KB Output is correct
7 Correct 1 ms 7260 KB Output is correct
8 Correct 1 ms 7260 KB Output is correct
9 Correct 1 ms 7260 KB Output is correct
10 Correct 1 ms 7260 KB Output is correct
11 Correct 1 ms 7260 KB Output is correct
12 Correct 1 ms 7260 KB Output is correct
13 Correct 1 ms 7260 KB Output is correct
14 Correct 1 ms 7260 KB Output is correct
15 Correct 2 ms 7348 KB Output is correct
16 Correct 2 ms 7260 KB Output is correct
17 Correct 1 ms 7260 KB Output is correct
18 Correct 2 ms 7260 KB Output is correct
19 Correct 2 ms 7260 KB Output is correct
20 Correct 2 ms 7256 KB Output is correct
21 Correct 2 ms 7260 KB Output is correct
22 Correct 2 ms 7260 KB Output is correct
23 Correct 2 ms 7260 KB Output is correct
24 Correct 13 ms 11996 KB Output is correct
25 Correct 13 ms 12124 KB Output is correct
26 Correct 13 ms 12120 KB Output is correct
27 Correct 2 ms 7516 KB Output is correct
28 Correct 3 ms 7516 KB Output is correct
29 Correct 2 ms 7516 KB Output is correct
30 Correct 2 ms 7516 KB Output is correct
31 Correct 2 ms 7516 KB Output is correct
32 Correct 2 ms 7516 KB Output is correct
33 Correct 396 ms 8776 KB Output is correct
34 Correct 385 ms 8788 KB Output is correct
35 Correct 376 ms 8760 KB Output is correct
36 Correct 408 ms 8772 KB Output is correct
37 Correct 378 ms 8768 KB Output is correct
38 Correct 373 ms 8768 KB Output is correct
39 Correct 672 ms 12752 KB Output is correct
40 Correct 654 ms 12636 KB Output is correct
41 Correct 664 ms 12632 KB Output is correct
42 Correct 1 ms 7260 KB Output is correct
43 Correct 1 ms 7260 KB Output is correct
44 Correct 1 ms 7260 KB Output is correct
45 Correct 1 ms 7260 KB Output is correct
46 Correct 1 ms 7352 KB Output is correct
47 Correct 1 ms 7260 KB Output is correct
48 Correct 1 ms 7260 KB Output is correct
49 Correct 1 ms 7260 KB Output is correct
50 Correct 1 ms 7260 KB Output is correct
51 Correct 1 ms 7260 KB Output is correct
52 Correct 1 ms 7260 KB Output is correct
53 Correct 1 ms 7260 KB Output is correct
54 Correct 2 ms 7352 KB Output is correct
55 Correct 1 ms 7260 KB Output is correct
56 Correct 1 ms 7260 KB Output is correct
57 Correct 1 ms 7260 KB Output is correct
58 Correct 1 ms 7260 KB Output is correct
59 Correct 1 ms 7344 KB Output is correct
60 Correct 1 ms 7260 KB Output is correct
61 Correct 1 ms 7260 KB Output is correct
62 Correct 1 ms 7260 KB Output is correct
63 Correct 1 ms 7260 KB Output is correct
64 Correct 1 ms 7260 KB Output is correct
65 Correct 1 ms 7260 KB Output is correct
66 Correct 2 ms 7260 KB Output is correct
67 Correct 1 ms 7260 KB Output is correct
68 Correct 2 ms 7260 KB Output is correct
69 Correct 2 ms 7260 KB Output is correct
70 Correct 1 ms 7260 KB Output is correct
71 Correct 2 ms 7260 KB Output is correct
72 Correct 2 ms 7260 KB Output is correct
73 Correct 2 ms 7260 KB Output is correct
74 Correct 2 ms 7260 KB Output is correct
75 Correct 2 ms 7260 KB Output is correct
76 Correct 2 ms 7260 KB Output is correct
77 Correct 2 ms 7260 KB Output is correct
78 Correct 2 ms 7260 KB Output is correct
79 Correct 2 ms 7260 KB Output is correct
80 Correct 2 ms 7260 KB Output is correct
81 Correct 1 ms 7260 KB Output is correct
82 Correct 1 ms 7260 KB Output is correct
83 Correct 1 ms 7260 KB Output is correct
84 Correct 1 ms 7256 KB Output is correct
85 Correct 3 ms 7772 KB Output is correct
86 Correct 3 ms 8024 KB Output is correct
87 Correct 3 ms 7772 KB Output is correct
88 Correct 2 ms 7512 KB Output is correct
89 Correct 3 ms 7772 KB Output is correct
90 Correct 3 ms 7772 KB Output is correct
91 Correct 14 ms 12632 KB Output is correct
92 Correct 14 ms 13240 KB Output is correct
93 Correct 16 ms 14200 KB Output is correct
94 Correct 2 ms 7260 KB Output is correct
95 Correct 1 ms 7260 KB Output is correct
96 Correct 1 ms 7260 KB Output is correct
97 Correct 2 ms 7260 KB Output is correct
98 Correct 2 ms 7260 KB Output is correct
99 Correct 4 ms 8028 KB Output is correct
100 Correct 5 ms 8028 KB Output is correct
101 Correct 4 ms 8108 KB Output is correct
102 Correct 4 ms 8028 KB Output is correct
103 Correct 4 ms 8028 KB Output is correct
104 Correct 4 ms 8028 KB Output is correct
105 Correct 20 ms 15288 KB Output is correct
106 Correct 21 ms 15244 KB Output is correct
107 Correct 22 ms 15196 KB Output is correct
108 Correct 2 ms 7512 KB Output is correct
109 Correct 25 ms 7764 KB Output is correct
110 Correct 19 ms 7720 KB Output is correct
111 Correct 18 ms 7720 KB Output is correct
112 Correct 25 ms 7776 KB Output is correct
113 Correct 23 ms 7772 KB Output is correct
114 Correct 181 ms 10076 KB Output is correct
115 Correct 20 ms 10328 KB Output is correct
116 Correct 196 ms 11100 KB Output is correct
117 Correct 96 ms 10328 KB Output is correct
118 Correct 28 ms 11096 KB Output is correct
119 Correct 276 ms 9884 KB Output is correct
120 Correct 364 ms 12016 KB Output is correct
121 Correct 161 ms 8340 KB Output is correct
122 Correct 116 ms 13296 KB Output is correct
123 Correct 45 ms 8024 KB Output is correct
124 Correct 61 ms 13916 KB Output is correct
125 Correct 38 ms 8516 KB Output is correct
126 Correct 9 ms 8792 KB Output is correct
127 Correct 129 ms 9044 KB Output is correct
128 Correct 22 ms 8628 KB Output is correct
129 Correct 36 ms 8536 KB Output is correct
130 Correct 2 ms 7516 KB Output is correct
131 Correct 35 ms 7800 KB Output is correct
132 Correct 37 ms 7772 KB Output is correct
133 Correct 51 ms 7772 KB Output is correct
134 Correct 42 ms 7892 KB Output is correct
135 Correct 48 ms 7772 KB Output is correct
136 Correct 520 ms 11868 KB Output is correct
137 Correct 564 ms 11868 KB Output is correct
138 Correct 527 ms 11772 KB Output is correct
139 Correct 535 ms 11880 KB Output is correct
140 Correct 522 ms 11868 KB Output is correct
141 Correct 523 ms 11868 KB Output is correct
142 Correct 573 ms 15884 KB Output is correct
143 Correct 383 ms 8784 KB Output is correct
144 Correct 563 ms 15816 KB Output is correct
145 Correct 395 ms 8788 KB Output is correct
146 Correct 578 ms 15740 KB Output is correct
147 Correct 387 ms 8788 KB Output is correct
148 Correct 403 ms 9452 KB Output is correct
149 Correct 195 ms 9308 KB Output is correct
150 Correct 163 ms 9048 KB Output is correct
151 Correct 139 ms 9028 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 7256 KB Output is correct
2 Correct 1 ms 7260 KB Output is correct
3 Correct 2 ms 7260 KB Output is correct
4 Correct 1 ms 7300 KB Output is correct
5 Correct 2 ms 7260 KB Output is correct
6 Correct 2 ms 7260 KB Output is correct
7 Correct 1 ms 7260 KB Output is correct
8 Correct 1 ms 7260 KB Output is correct
9 Correct 1 ms 7260 KB Output is correct
10 Correct 1 ms 7260 KB Output is correct
11 Correct 1 ms 7260 KB Output is correct
12 Correct 1 ms 7260 KB Output is correct
13 Correct 1 ms 7260 KB Output is correct
14 Correct 1 ms 7260 KB Output is correct
15 Correct 2 ms 7348 KB Output is correct
16 Correct 2 ms 7260 KB Output is correct
17 Correct 1 ms 7260 KB Output is correct
18 Correct 2 ms 7260 KB Output is correct
19 Correct 2 ms 7260 KB Output is correct
20 Correct 2 ms 7256 KB Output is correct
21 Correct 2 ms 7260 KB Output is correct
22 Correct 2 ms 7260 KB Output is correct
23 Correct 2 ms 7260 KB Output is correct
24 Correct 13 ms 11996 KB Output is correct
25 Correct 13 ms 12124 KB Output is correct
26 Correct 13 ms 12120 KB Output is correct
27 Correct 2 ms 7516 KB Output is correct
28 Correct 3 ms 7516 KB Output is correct
29 Correct 2 ms 7516 KB Output is correct
30 Correct 2 ms 7516 KB Output is correct
31 Correct 2 ms 7516 KB Output is correct
32 Correct 2 ms 7516 KB Output is correct
33 Correct 396 ms 8776 KB Output is correct
34 Correct 385 ms 8788 KB Output is correct
35 Correct 376 ms 8760 KB Output is correct
36 Correct 408 ms 8772 KB Output is correct
37 Correct 378 ms 8768 KB Output is correct
38 Correct 373 ms 8768 KB Output is correct
39 Correct 672 ms 12752 KB Output is correct
40 Correct 654 ms 12636 KB Output is correct
41 Correct 664 ms 12632 KB Output is correct
42 Correct 5 ms 8540 KB Output is correct
43 Correct 4 ms 8268 KB Output is correct
44 Correct 7 ms 9044 KB Output is correct
45 Correct 5 ms 8284 KB Output is correct
46 Correct 5 ms 8284 KB Output is correct
47 Correct 7 ms 8796 KB Output is correct
48 Execution timed out 1542 ms 23120 KB Time limit exceeded
49 Halted 0 ms 0 KB -