답안 #985089

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
985089 2024-05-17T10:33:08 Z nnin 벽 칠하기 (APIO20_paint) C++14
12 / 100
46 ms 13704 KB
#include "paint.h"
#include<bits/stdc++.h>
using namespace std;

vector<int> f[100005];
/*bool poss[100005];

int seg[4*200005];
void update(int i, int l, int r, int x, int val) {
  if(l==r) {
    seg[i] += val;
    return;
  }
  int m = (l+r)/2;
  if(x<=m) update(i*2+1, l, m, x, val);
  else update(i*2+2, m+1, r, x, val);
  seg[i] = max(seg[i*2+1], seg[i*2+2]);
}

int dp[100005];*/

int minimumInstructions(int N, int M, int K, std::vector<int> C, vector<int> A, vector<vector<int>> B) {
  for(int i=0;i<M;i++) {
    for(int k:B[i]) f[k].push_back(i);
  }
  /*for(int i=0;i<M;i++) {
    for(int p:f[C[i]]) update(0, 0, (int)1e5, (p-(i%M)+M)%M, 1);
  }
  if(seg[0]==M) poss[M-1] = 1;
  else return -1;
  for(int i=M;i<N;i++) {
    for(int p:f[C[i-M]]) update(0, 0, (int)1e5, (p-(i%M)+M)%M, -1);
    for(int p:f[C[i]]) update(0, 0, (int)1e5, (p-(i%M)+M)%M, 1);
    if(seg[0]==M) poss[i] = 1;
  }
  int last = M-1;
  for(int i=0;i<=last;i++) dp[i] = 1;
  for(int i=M;i<N;i++) {
    if(last<i-M) return -1;
    if(!poss[i]) continue;
    for(int j=last+1;j<=i;j++) dp[j] = dp[i-M]+1;
    last = i;
  }
  return dp[N-1];*/
  for(int i=0;i<N;i++) {
    if(f[C[i]].empty()) return -1;
  }
  for(int i=1;i<N;i++) {
    int last = f[C[i-1]][0];
    int cur = f[C[i]][0];
    if((last+1)%M!=cur) return -1;
  }
  return (N+M-1)/M;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 1 ms 2652 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 1 ms 2904 KB Output is correct
13 Correct 1 ms 2652 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 1 ms 2908 KB Output is correct
17 Correct 1 ms 2652 KB Output is correct
18 Correct 1 ms 2652 KB Output is correct
19 Correct 2 ms 2652 KB Output is correct
20 Correct 2 ms 2792 KB Output is correct
21 Correct 2 ms 2792 KB Output is correct
22 Correct 15 ms 7252 KB Output is correct
23 Correct 16 ms 7216 KB Output is correct
24 Correct 24 ms 7148 KB Output is correct
25 Correct 2 ms 2904 KB Output is correct
26 Correct 2 ms 2908 KB Output is correct
27 Correct 3 ms 2796 KB Output is correct
28 Correct 3 ms 2908 KB Output is correct
29 Correct 2 ms 2908 KB Output is correct
30 Correct 2 ms 2908 KB Output is correct
31 Correct 5 ms 3932 KB Output is correct
32 Correct 6 ms 3924 KB Output is correct
33 Correct 7 ms 4016 KB Output is correct
34 Correct 6 ms 3944 KB Output is correct
35 Correct 7 ms 3868 KB Output is correct
36 Correct 5 ms 3928 KB Output is correct
37 Correct 18 ms 7512 KB Output is correct
38 Correct 22 ms 7504 KB Output is correct
39 Correct 15 ms 7580 KB Output is correct
40 Correct 10 ms 3580 KB Output is correct
41 Correct 5 ms 3164 KB Output is correct
42 Correct 8 ms 3556 KB Output is correct
43 Correct 5 ms 3420 KB Output is correct
44 Correct 5 ms 3160 KB Output is correct
45 Correct 7 ms 3676 KB Output is correct
46 Correct 27 ms 12712 KB Output is correct
47 Correct 19 ms 8428 KB Output is correct
48 Correct 22 ms 10832 KB Output is correct
49 Correct 28 ms 11344 KB Output is correct
50 Correct 29 ms 10840 KB Output is correct
51 Correct 19 ms 8536 KB Output is correct
52 Correct 7 ms 3676 KB Output is correct
53 Correct 7 ms 3676 KB Output is correct
54 Correct 7 ms 3676 KB Output is correct
55 Correct 11 ms 3832 KB Output is correct
56 Correct 9 ms 3672 KB Output is correct
57 Correct 11 ms 3676 KB Output is correct
58 Correct 30 ms 13676 KB Output is correct
59 Correct 30 ms 13656 KB Output is correct
60 Correct 30 ms 13648 KB Output is correct
61 Correct 46 ms 13660 KB Output is correct
62 Correct 30 ms 13660 KB Output is correct
63 Correct 43 ms 13704 KB Output is correct
64 Correct 39 ms 12868 KB Output is correct
65 Correct 31 ms 13024 KB Output is correct
66 Correct 32 ms 12984 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 1 ms 2652 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 1 ms 2904 KB Output is correct
13 Correct 1 ms 2652 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 1 ms 2908 KB Output is correct
17 Correct 1 ms 2652 KB Output is correct
18 Correct 1 ms 2652 KB Output is correct
19 Correct 2 ms 2652 KB Output is correct
20 Correct 2 ms 2792 KB Output is correct
21 Correct 2 ms 2792 KB Output is correct
22 Incorrect 1 ms 2648 KB Output isn't correct
23 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2648 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2648 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2648 KB Output isn't correct
2 Halted 0 ms 0 KB -