답안 #954204

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
954204 2024-03-27T11:49:59 Z vjudge1 벽 칠하기 (APIO20_paint) C++17
12 / 100
48 ms 15700 KB
#include "paint.h"
#include<bits/stdc++.h>
using namespace std;
const int maxn=100000+10;
int n,m,k;
vector<int>allk[maxn];
int len[maxn],last[maxn],fakelast[maxn],fakelen[maxn];

int minimumInstructions(int N, int M, int K, std::vector<int> C,
    std::vector<int> A, std::vector<std::vector<int>> B) {
    n=N;
    m=M;
    k=K;
    for(int i=0;i<m;i++){
        for(auto x:B[i]){
            allk[x].push_back(i);
        }
    }
    vector<int>res(n+2);
    for(int i=0;i<maxn;i++){
        last[i]=n;
    }
    for(int i=n-1;i>=0;i--){
        for(auto x:allk[C[i]]){
            fakelast[x]=i;
            if(last[(x+1)%m]!=i+1){
                fakelen[x]=1;
            }else{
                fakelen[x]=min(m,fakelen[(x+1)%m]+1);
            }
        }
        for(auto x:allk[C[i]]){
            last[x]=fakelast[x];
            len[x]=fakelen[x];
            if(len[x]==m){
                res[i]=1;
            }
        }
    }
    int ted=0;
    if(res[0]==0){
        return -1;
    }
    int mx=-1,fakemx=-1;
    while(mx!=n-1){
      //  cout<<mx<<" "<<fakemx<<endl;
        ted++;
        fakemx=max(fakemx,res[mx+1]*m+mx);
        if(fakemx==mx){
            return -1;
        }
        int j=mx;
        mx=fakemx;
        for(;j<=mx;j++){
            fakemx=max(fakemx,res[j+1]*m+j);
        }
    }
    return ted;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4084 KB Output is correct
2 Correct 3 ms 4444 KB Output is correct
3 Correct 2 ms 3932 KB Output is correct
4 Correct 2 ms 3928 KB Output is correct
5 Correct 1 ms 3932 KB Output is correct
6 Correct 1 ms 3932 KB Output is correct
7 Correct 2 ms 3932 KB Output is correct
8 Correct 2 ms 4188 KB Output is correct
9 Correct 2 ms 3932 KB Output is correct
10 Correct 2 ms 4172 KB Output is correct
11 Correct 1 ms 4168 KB Output is correct
12 Correct 2 ms 4184 KB Output is correct
13 Correct 2 ms 4192 KB Output is correct
14 Correct 2 ms 4188 KB Output is correct
15 Correct 2 ms 4340 KB Output is correct
16 Correct 2 ms 4192 KB Output is correct
17 Correct 2 ms 4188 KB Output is correct
18 Correct 2 ms 4192 KB Output is correct
19 Correct 2 ms 4188 KB Output is correct
20 Correct 2 ms 4192 KB Output is correct
21 Correct 1 ms 4188 KB Output is correct
22 Correct 14 ms 8544 KB Output is correct
23 Correct 14 ms 8540 KB Output is correct
24 Correct 15 ms 8528 KB Output is correct
25 Correct 3 ms 4448 KB Output is correct
26 Correct 3 ms 4444 KB Output is correct
27 Correct 3 ms 4448 KB Output is correct
28 Correct 3 ms 4444 KB Output is correct
29 Correct 3 ms 4452 KB Output is correct
30 Correct 3 ms 4440 KB Output is correct
31 Correct 6 ms 5468 KB Output is correct
32 Correct 6 ms 5468 KB Output is correct
33 Correct 6 ms 5476 KB Output is correct
34 Correct 6 ms 5472 KB Output is correct
35 Correct 8 ms 5468 KB Output is correct
36 Correct 6 ms 5464 KB Output is correct
37 Correct 17 ms 9236 KB Output is correct
38 Correct 16 ms 9052 KB Output is correct
39 Correct 15 ms 9052 KB Output is correct
40 Correct 8 ms 5212 KB Output is correct
41 Correct 5 ms 4956 KB Output is correct
42 Correct 9 ms 5468 KB Output is correct
43 Correct 6 ms 4952 KB Output is correct
44 Correct 8 ms 4952 KB Output is correct
45 Correct 8 ms 5468 KB Output is correct
46 Correct 33 ms 14792 KB Output is correct
47 Correct 18 ms 10064 KB Output is correct
48 Correct 23 ms 12632 KB Output is correct
49 Correct 27 ms 13148 KB Output is correct
50 Correct 28 ms 12620 KB Output is correct
51 Correct 21 ms 10284 KB Output is correct
52 Correct 8 ms 5468 KB Output is correct
53 Correct 8 ms 5468 KB Output is correct
54 Correct 10 ms 5468 KB Output is correct
55 Correct 9 ms 5464 KB Output is correct
56 Correct 9 ms 5468 KB Output is correct
57 Correct 8 ms 5464 KB Output is correct
58 Correct 32 ms 15700 KB Output is correct
59 Correct 35 ms 15696 KB Output is correct
60 Correct 48 ms 15604 KB Output is correct
61 Correct 34 ms 15696 KB Output is correct
62 Correct 33 ms 15700 KB Output is correct
63 Correct 34 ms 15700 KB Output is correct
64 Correct 34 ms 14928 KB Output is correct
65 Correct 33 ms 14928 KB Output is correct
66 Correct 35 ms 14940 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4084 KB Output is correct
2 Correct 3 ms 4444 KB Output is correct
3 Correct 2 ms 3932 KB Output is correct
4 Correct 2 ms 3928 KB Output is correct
5 Correct 1 ms 3932 KB Output is correct
6 Correct 1 ms 3932 KB Output is correct
7 Correct 2 ms 3932 KB Output is correct
8 Correct 2 ms 4188 KB Output is correct
9 Correct 2 ms 3932 KB Output is correct
10 Correct 2 ms 4172 KB Output is correct
11 Correct 1 ms 4168 KB Output is correct
12 Correct 2 ms 4184 KB Output is correct
13 Correct 2 ms 4192 KB Output is correct
14 Correct 2 ms 4188 KB Output is correct
15 Correct 2 ms 4340 KB Output is correct
16 Correct 2 ms 4192 KB Output is correct
17 Correct 2 ms 4188 KB Output is correct
18 Correct 2 ms 4192 KB Output is correct
19 Correct 2 ms 4188 KB Output is correct
20 Correct 2 ms 4192 KB Output is correct
21 Correct 1 ms 4188 KB Output is correct
22 Correct 2 ms 3928 KB Output is correct
23 Correct 1 ms 3932 KB Output is correct
24 Correct 1 ms 3932 KB Output is correct
25 Correct 1 ms 3932 KB Output is correct
26 Correct 2 ms 4188 KB Output is correct
27 Incorrect 1 ms 4188 KB Output isn't correct
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3928 KB Output is correct
2 Correct 1 ms 3932 KB Output is correct
3 Correct 1 ms 4084 KB Output is correct
4 Correct 3 ms 4444 KB Output is correct
5 Correct 2 ms 3932 KB Output is correct
6 Correct 2 ms 3928 KB Output is correct
7 Correct 1 ms 3932 KB Output is correct
8 Correct 1 ms 3932 KB Output is correct
9 Correct 2 ms 3932 KB Output is correct
10 Correct 2 ms 4188 KB Output is correct
11 Correct 2 ms 3932 KB Output is correct
12 Correct 2 ms 4172 KB Output is correct
13 Correct 1 ms 4168 KB Output is correct
14 Correct 2 ms 4184 KB Output is correct
15 Correct 2 ms 4192 KB Output is correct
16 Correct 2 ms 4188 KB Output is correct
17 Correct 2 ms 4340 KB Output is correct
18 Correct 2 ms 4192 KB Output is correct
19 Correct 2 ms 4188 KB Output is correct
20 Correct 2 ms 4192 KB Output is correct
21 Correct 2 ms 4188 KB Output is correct
22 Correct 2 ms 4192 KB Output is correct
23 Correct 1 ms 4188 KB Output is correct
24 Correct 14 ms 8544 KB Output is correct
25 Correct 14 ms 8540 KB Output is correct
26 Correct 15 ms 8528 KB Output is correct
27 Correct 1 ms 3932 KB Output is correct
28 Correct 1 ms 3932 KB Output is correct
29 Correct 2 ms 4188 KB Output is correct
30 Incorrect 1 ms 4188 KB Output isn't correct
31 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3928 KB Output is correct
2 Correct 1 ms 3932 KB Output is correct
3 Correct 1 ms 4084 KB Output is correct
4 Correct 3 ms 4444 KB Output is correct
5 Correct 2 ms 3932 KB Output is correct
6 Correct 2 ms 3928 KB Output is correct
7 Correct 1 ms 3932 KB Output is correct
8 Correct 1 ms 3932 KB Output is correct
9 Correct 2 ms 3932 KB Output is correct
10 Correct 2 ms 4188 KB Output is correct
11 Correct 2 ms 3932 KB Output is correct
12 Correct 2 ms 4172 KB Output is correct
13 Correct 1 ms 4168 KB Output is correct
14 Correct 2 ms 4184 KB Output is correct
15 Correct 2 ms 4192 KB Output is correct
16 Correct 2 ms 4188 KB Output is correct
17 Correct 2 ms 4340 KB Output is correct
18 Correct 2 ms 4192 KB Output is correct
19 Correct 2 ms 4188 KB Output is correct
20 Correct 2 ms 4192 KB Output is correct
21 Correct 2 ms 4188 KB Output is correct
22 Correct 2 ms 4192 KB Output is correct
23 Correct 1 ms 4188 KB Output is correct
24 Correct 14 ms 8544 KB Output is correct
25 Correct 14 ms 8540 KB Output is correct
26 Correct 15 ms 8528 KB Output is correct
27 Correct 3 ms 4448 KB Output is correct
28 Correct 3 ms 4444 KB Output is correct
29 Correct 3 ms 4448 KB Output is correct
30 Correct 3 ms 4444 KB Output is correct
31 Correct 3 ms 4452 KB Output is correct
32 Correct 3 ms 4440 KB Output is correct
33 Correct 6 ms 5468 KB Output is correct
34 Correct 6 ms 5468 KB Output is correct
35 Correct 6 ms 5476 KB Output is correct
36 Correct 6 ms 5472 KB Output is correct
37 Correct 8 ms 5468 KB Output is correct
38 Correct 6 ms 5464 KB Output is correct
39 Correct 17 ms 9236 KB Output is correct
40 Correct 16 ms 9052 KB Output is correct
41 Correct 15 ms 9052 KB Output is correct
42 Correct 1 ms 3932 KB Output is correct
43 Correct 1 ms 3932 KB Output is correct
44 Correct 2 ms 4188 KB Output is correct
45 Incorrect 1 ms 4188 KB Output isn't correct
46 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3928 KB Output is correct
2 Correct 1 ms 3932 KB Output is correct
3 Correct 1 ms 4084 KB Output is correct
4 Correct 3 ms 4444 KB Output is correct
5 Correct 2 ms 3932 KB Output is correct
6 Correct 2 ms 3928 KB Output is correct
7 Correct 1 ms 3932 KB Output is correct
8 Correct 1 ms 3932 KB Output is correct
9 Correct 2 ms 3932 KB Output is correct
10 Correct 2 ms 4188 KB Output is correct
11 Correct 2 ms 3932 KB Output is correct
12 Correct 2 ms 4172 KB Output is correct
13 Correct 1 ms 4168 KB Output is correct
14 Correct 2 ms 4184 KB Output is correct
15 Correct 2 ms 4192 KB Output is correct
16 Correct 2 ms 4188 KB Output is correct
17 Correct 2 ms 4340 KB Output is correct
18 Correct 2 ms 4192 KB Output is correct
19 Correct 2 ms 4188 KB Output is correct
20 Correct 2 ms 4192 KB Output is correct
21 Correct 2 ms 4188 KB Output is correct
22 Correct 2 ms 4192 KB Output is correct
23 Correct 1 ms 4188 KB Output is correct
24 Correct 14 ms 8544 KB Output is correct
25 Correct 14 ms 8540 KB Output is correct
26 Correct 15 ms 8528 KB Output is correct
27 Correct 3 ms 4448 KB Output is correct
28 Correct 3 ms 4444 KB Output is correct
29 Correct 3 ms 4448 KB Output is correct
30 Correct 3 ms 4444 KB Output is correct
31 Correct 3 ms 4452 KB Output is correct
32 Correct 3 ms 4440 KB Output is correct
33 Correct 6 ms 5468 KB Output is correct
34 Correct 6 ms 5468 KB Output is correct
35 Correct 6 ms 5476 KB Output is correct
36 Correct 6 ms 5472 KB Output is correct
37 Correct 8 ms 5468 KB Output is correct
38 Correct 6 ms 5464 KB Output is correct
39 Correct 17 ms 9236 KB Output is correct
40 Correct 16 ms 9052 KB Output is correct
41 Correct 15 ms 9052 KB Output is correct
42 Correct 8 ms 5212 KB Output is correct
43 Correct 5 ms 4956 KB Output is correct
44 Correct 9 ms 5468 KB Output is correct
45 Correct 6 ms 4952 KB Output is correct
46 Correct 8 ms 4952 KB Output is correct
47 Correct 8 ms 5468 KB Output is correct
48 Correct 33 ms 14792 KB Output is correct
49 Correct 18 ms 10064 KB Output is correct
50 Correct 23 ms 12632 KB Output is correct
51 Correct 27 ms 13148 KB Output is correct
52 Correct 28 ms 12620 KB Output is correct
53 Correct 21 ms 10284 KB Output is correct
54 Correct 8 ms 5468 KB Output is correct
55 Correct 8 ms 5468 KB Output is correct
56 Correct 10 ms 5468 KB Output is correct
57 Correct 9 ms 5464 KB Output is correct
58 Correct 9 ms 5468 KB Output is correct
59 Correct 8 ms 5464 KB Output is correct
60 Correct 32 ms 15700 KB Output is correct
61 Correct 35 ms 15696 KB Output is correct
62 Correct 48 ms 15604 KB Output is correct
63 Correct 34 ms 15696 KB Output is correct
64 Correct 33 ms 15700 KB Output is correct
65 Correct 34 ms 15700 KB Output is correct
66 Correct 34 ms 14928 KB Output is correct
67 Correct 33 ms 14928 KB Output is correct
68 Correct 35 ms 14940 KB Output is correct
69 Correct 1 ms 3932 KB Output is correct
70 Correct 1 ms 3932 KB Output is correct
71 Correct 2 ms 4188 KB Output is correct
72 Incorrect 1 ms 4188 KB Output isn't correct
73 Halted 0 ms 0 KB -