Submission #134171

# Submission time Handle Problem Language Result Execution time Memory
134171 2019-07-22T07:45:07 Z dragonslayerit Lottery (CEOI18_lot) C++14
100 / 100
993 ms 8400 KB
#include <cstdio>
#include <algorithm>

int as[10001];
std::pair<int,int> ks[101];

int mismatch[10001];

int down[10001];

int ans[101][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].first);
    ks[i].second=i;
  }
  std::sort(ks,ks+Q);
  ks[Q].first=10001;
  for(int x=0;x<=10000;x++){
    for(int q=0;q<=Q;q++){
      if(x<=ks[q].first){
	down[x]=q;
	break;
      }
    }
  }
  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].first){
	  ans[q][i]++;
	  ans[q][i+shift]++;
	}
      }
    }
    */
    for(int i=0;i<=N-L-shift;i++){
      ans[down[mismatch[i]]][i]++;
      ans[down[mismatch[i]]][i+shift]++;
    }
  }
  for(int q=1;q<Q;q++){
    for(int i=0;i<=N-L;i++){
      ans[q][i]+=ans[q-1][i];
    }
  }
  for(int q=0;q<Q;q++){
    for(int k=0;k<Q;k++){
      if(ks[k].second==q){
	for(int i=0;i<=N-L;i++){
	  if(i) printf(" ");
	  printf("%d",ans[k][i]);
	}
	printf("\n");
	break;
      }
    }
  }
}

Compilation message

lot.cpp: In function 'int main()':
lot.cpp:15: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:17:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&as[i]);
     ~~~~~^~~~~~~~~~~~~
lot.cpp:20:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&Q);
   ~~~~~^~~~~~~~~
lot.cpp:22:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&ks[i].first);
     ~~~~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 380 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 504 KB Output is correct
9 Correct 3 ms 504 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 3 ms 504 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 380 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 504 KB Output is correct
9 Correct 3 ms 504 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 3 ms 504 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
13 Correct 31 ms 508 KB Output is correct
14 Correct 19 ms 556 KB Output is correct
15 Correct 18 ms 508 KB Output is correct
16 Correct 28 ms 616 KB Output is correct
17 Correct 26 ms 632 KB Output is correct
18 Correct 25 ms 636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 884 ms 540 KB Output is correct
2 Correct 866 ms 576 KB Output is correct
3 Correct 699 ms 632 KB Output is correct
4 Correct 619 ms 632 KB Output is correct
5 Correct 198 ms 504 KB Output is correct
6 Correct 570 ms 760 KB Output is correct
7 Correct 165 ms 504 KB Output is correct
8 Correct 295 ms 480 KB Output is correct
9 Correct 601 ms 632 KB Output is correct
10 Correct 617 ms 548 KB Output is correct
11 Correct 32 ms 376 KB Output is correct
12 Correct 347 ms 504 KB Output is correct
13 Correct 287 ms 504 KB Output is correct
14 Correct 283 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 884 ms 540 KB Output is correct
2 Correct 866 ms 576 KB Output is correct
3 Correct 699 ms 632 KB Output is correct
4 Correct 619 ms 632 KB Output is correct
5 Correct 198 ms 504 KB Output is correct
6 Correct 570 ms 760 KB Output is correct
7 Correct 165 ms 504 KB Output is correct
8 Correct 295 ms 480 KB Output is correct
9 Correct 601 ms 632 KB Output is correct
10 Correct 617 ms 548 KB Output is correct
11 Correct 32 ms 376 KB Output is correct
12 Correct 347 ms 504 KB Output is correct
13 Correct 287 ms 504 KB Output is correct
14 Correct 283 ms 504 KB Output is correct
15 Correct 665 ms 504 KB Output is correct
16 Correct 542 ms 888 KB Output is correct
17 Correct 642 ms 604 KB Output is correct
18 Correct 643 ms 760 KB Output is correct
19 Correct 626 ms 540 KB Output is correct
20 Correct 628 ms 632 KB Output is correct
21 Correct 633 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 380 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 504 KB Output is correct
9 Correct 3 ms 504 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 3 ms 504 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
13 Correct 31 ms 508 KB Output is correct
14 Correct 19 ms 556 KB Output is correct
15 Correct 18 ms 508 KB Output is correct
16 Correct 28 ms 616 KB Output is correct
17 Correct 26 ms 632 KB Output is correct
18 Correct 25 ms 636 KB Output is correct
19 Correct 884 ms 540 KB Output is correct
20 Correct 866 ms 576 KB Output is correct
21 Correct 699 ms 632 KB Output is correct
22 Correct 619 ms 632 KB Output is correct
23 Correct 198 ms 504 KB Output is correct
24 Correct 570 ms 760 KB Output is correct
25 Correct 165 ms 504 KB Output is correct
26 Correct 295 ms 480 KB Output is correct
27 Correct 601 ms 632 KB Output is correct
28 Correct 617 ms 548 KB Output is correct
29 Correct 32 ms 376 KB Output is correct
30 Correct 347 ms 504 KB Output is correct
31 Correct 287 ms 504 KB Output is correct
32 Correct 283 ms 504 KB Output is correct
33 Correct 665 ms 504 KB Output is correct
34 Correct 542 ms 888 KB Output is correct
35 Correct 642 ms 604 KB Output is correct
36 Correct 643 ms 760 KB Output is correct
37 Correct 626 ms 540 KB Output is correct
38 Correct 628 ms 632 KB Output is correct
39 Correct 633 ms 632 KB Output is correct
40 Correct 889 ms 1972 KB Output is correct
41 Correct 35 ms 632 KB Output is correct
42 Correct 653 ms 2048 KB Output is correct
43 Correct 618 ms 1912 KB Output is correct
44 Correct 627 ms 1656 KB Output is correct
45 Correct 993 ms 8316 KB Output is correct
46 Correct 45 ms 1528 KB Output is correct
47 Correct 741 ms 8400 KB Output is correct
48 Correct 705 ms 6520 KB Output is correct
49 Correct 707 ms 7288 KB Output is correct