답안 #134156

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
134156 2019-07-22T07:30:07 Z dragonslayerit Lottery (CEOI18_lot) C++14
80 / 100
3000 ms 3376 KB
#include <cstdio>
#include <algorithm>

int as[10001];
int ks[101];

int mismatch[10001];

int ans[100][10001];

int main(){
  int N,L;
  scanf("%d %d",&N,&L);
  for(int i=0;i<N;i++){
    scanf("%d",&as[i]);
  }
  int Q;
  scanf("%d",&Q);
  for(int i=0;i<Q;i++){
    scanf("%d",&ks[i]);
  }
  for(int shift=1;shift+L<=N;shift++){
    std::fill(mismatch,mismatch+N-L-shift+1,0);
    for(int i=0;i+shift<N;i++){
      if(as[i]!=as[i+shift]){
	mismatch[std::max(0,i-L+1)]++;
	mismatch[std::min(i,N-L-shift)+1]--;
      }
    }
    for(int i=1;i<=N-L-shift;i++){
      mismatch[i]+=mismatch[i-1];
    }
    for(int q=0;q<Q;q++){
      for(int i=0;i<=N-L-shift;i++){
	//printf("[%d,%d] and [%d,%d]: %d\n",i,i+L-1,i+shift,i+shift+L-1,mismatch[i]);
	if(mismatch[i]<=ks[q]){
	  ans[q][i]++;
	  ans[q][i+shift]++;
	}
      }
    }
  }
  for(int q=0;q<Q;q++){
    for(int i=0;i<=N-L;i++){
      if(i) printf(" ");
      printf("%d",ans[q][i]);
    }
    printf("\n");
  }
}

Compilation message

lot.cpp: In function 'int main()':
lot.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d",&N,&L);
   ~~~~~^~~~~~~~~~~~~~~
lot.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&as[i]);
     ~~~~~^~~~~~~~~~~~~
lot.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&Q);
   ~~~~~^~~~~~~~~
lot.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&ks[i]);
     ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 4 ms 376 KB Output is correct
11 Correct 4 ms 376 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 4 ms 376 KB Output is correct
11 Correct 4 ms 376 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 33 ms 376 KB Output is correct
14 Correct 30 ms 388 KB Output is correct
15 Correct 21 ms 508 KB Output is correct
16 Correct 45 ms 632 KB Output is correct
17 Correct 41 ms 632 KB Output is correct
18 Correct 41 ms 496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 626 ms 500 KB Output is correct
2 Correct 560 ms 504 KB Output is correct
3 Correct 406 ms 504 KB Output is correct
4 Correct 327 ms 376 KB Output is correct
5 Correct 120 ms 504 KB Output is correct
6 Correct 309 ms 504 KB Output is correct
7 Correct 95 ms 504 KB Output is correct
8 Correct 158 ms 376 KB Output is correct
9 Correct 320 ms 504 KB Output is correct
10 Correct 331 ms 504 KB Output is correct
11 Correct 23 ms 376 KB Output is correct
12 Correct 209 ms 376 KB Output is correct
13 Correct 179 ms 376 KB Output is correct
14 Correct 184 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 626 ms 500 KB Output is correct
2 Correct 560 ms 504 KB Output is correct
3 Correct 406 ms 504 KB Output is correct
4 Correct 327 ms 376 KB Output is correct
5 Correct 120 ms 504 KB Output is correct
6 Correct 309 ms 504 KB Output is correct
7 Correct 95 ms 504 KB Output is correct
8 Correct 158 ms 376 KB Output is correct
9 Correct 320 ms 504 KB Output is correct
10 Correct 331 ms 504 KB Output is correct
11 Correct 23 ms 376 KB Output is correct
12 Correct 209 ms 376 KB Output is correct
13 Correct 179 ms 376 KB Output is correct
14 Correct 184 ms 512 KB Output is correct
15 Correct 421 ms 472 KB Output is correct
16 Correct 295 ms 504 KB Output is correct
17 Correct 344 ms 504 KB Output is correct
18 Correct 336 ms 520 KB Output is correct
19 Correct 337 ms 504 KB Output is correct
20 Correct 332 ms 504 KB Output is correct
21 Correct 334 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 4 ms 376 KB Output is correct
11 Correct 4 ms 376 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 33 ms 376 KB Output is correct
14 Correct 30 ms 388 KB Output is correct
15 Correct 21 ms 508 KB Output is correct
16 Correct 45 ms 632 KB Output is correct
17 Correct 41 ms 632 KB Output is correct
18 Correct 41 ms 496 KB Output is correct
19 Correct 626 ms 500 KB Output is correct
20 Correct 560 ms 504 KB Output is correct
21 Correct 406 ms 504 KB Output is correct
22 Correct 327 ms 376 KB Output is correct
23 Correct 120 ms 504 KB Output is correct
24 Correct 309 ms 504 KB Output is correct
25 Correct 95 ms 504 KB Output is correct
26 Correct 158 ms 376 KB Output is correct
27 Correct 320 ms 504 KB Output is correct
28 Correct 331 ms 504 KB Output is correct
29 Correct 23 ms 376 KB Output is correct
30 Correct 209 ms 376 KB Output is correct
31 Correct 179 ms 376 KB Output is correct
32 Correct 184 ms 512 KB Output is correct
33 Correct 421 ms 472 KB Output is correct
34 Correct 295 ms 504 KB Output is correct
35 Correct 344 ms 504 KB Output is correct
36 Correct 336 ms 520 KB Output is correct
37 Correct 337 ms 504 KB Output is correct
38 Correct 332 ms 504 KB Output is correct
39 Correct 334 ms 504 KB Output is correct
40 Correct 1917 ms 1796 KB Output is correct
41 Correct 41 ms 632 KB Output is correct
42 Correct 1227 ms 2012 KB Output is correct
43 Correct 1106 ms 1656 KB Output is correct
44 Correct 1112 ms 1656 KB Output is correct
45 Execution timed out 3029 ms 3376 KB Time limit exceeded
46 Halted 0 ms 0 KB -