답안 #503926

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
503926 2022-01-09T08:09:11 Z krit3379 Lottery (CEOI18_lot) C++14
100 / 100
500 ms 8272 KB
#include<bits/stdc++.h>
using namespace std;
#define N 10005

int a[N],ans[105][N],tr[N],tq[N],que[N];

int main(){
    int n,m,l,q,i,j,k,cnt,x,now;
    scanf("%d %d",&n,&l);
    for(i=1;i<=n;i++)scanf("%d",&a[i]);
    scanf("%d",&q);
    for(i=1;i<=q;i++){
        scanf("%d",&que[i]);
        tq[i]=que[i];
    }
    sort(tq+1,tq+q+1);
    tq[q+1]=2e9;
    now=1;
    for(i=0;i<=n;i++){
        while(i>tq[now])now++;
        tr[i]=now;
    }
    m=n-l+1;
    for(k=1;k<m;k++){
        cnt=0;
        for(i=1;i<=l;i++)cnt+=(a[i]!=a[i+k]);
        i=1;
        ans[tr[cnt]][i]++;
        ans[tr[cnt]][i+k]++;
        for(i=2;i+k+l-1<=n;i++){
            cnt+=(a[i+l-1]!=a[i+k+l-1])-(a[i-1]!=a[i+k-1]);
            ans[tr[cnt]][i]++;
            ans[tr[cnt]][i+k]++;
        }
    }
    for(i=1;i<=m;i++)for(j=1;j<=100;j++)ans[j][i]+=ans[j-1][i];
    for(i=1;i<=q;i++){
        for(j=1;j<=m;j++)printf("%d ",ans[tr[que[i]]][j]);
        printf("\n");
    }
    return 0;
}

Compilation message

lot.cpp: In function 'int main()':
lot.cpp:8:27: warning: unused variable 'x' [-Wunused-variable]
    8 |     int n,m,l,q,i,j,k,cnt,x,now;
      |                           ^
lot.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d %d",&n,&l);
      |     ~~~~~^~~~~~~~~~~~~~~
lot.cpp:10:27: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     for(i=1;i<=n;i++)scanf("%d",&a[i]);
      |                      ~~~~~^~~~~~~~~~~~
lot.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf("%d",&q);
      |     ~~~~~^~~~~~~~~
lot.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         scanf("%d",&que[i]);
      |         ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 716 KB Output is correct
2 Correct 1 ms 716 KB Output is correct
3 Correct 1 ms 716 KB Output is correct
4 Correct 1 ms 716 KB Output is correct
5 Correct 1 ms 716 KB Output is correct
6 Correct 1 ms 716 KB Output is correct
7 Correct 1 ms 716 KB Output is correct
8 Correct 1 ms 716 KB Output is correct
9 Correct 1 ms 716 KB Output is correct
10 Correct 1 ms 716 KB Output is correct
11 Correct 2 ms 844 KB Output is correct
12 Correct 1 ms 716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 716 KB Output is correct
2 Correct 1 ms 716 KB Output is correct
3 Correct 1 ms 716 KB Output is correct
4 Correct 1 ms 716 KB Output is correct
5 Correct 1 ms 716 KB Output is correct
6 Correct 1 ms 716 KB Output is correct
7 Correct 1 ms 716 KB Output is correct
8 Correct 1 ms 716 KB Output is correct
9 Correct 1 ms 716 KB Output is correct
10 Correct 1 ms 716 KB Output is correct
11 Correct 2 ms 844 KB Output is correct
12 Correct 1 ms 716 KB Output is correct
13 Correct 19 ms 1540 KB Output is correct
14 Correct 11 ms 1276 KB Output is correct
15 Correct 11 ms 1252 KB Output is correct
16 Correct 17 ms 1484 KB Output is correct
17 Correct 16 ms 1360 KB Output is correct
18 Correct 18 ms 1428 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 455 ms 4292 KB Output is correct
2 Correct 434 ms 4288 KB Output is correct
3 Correct 433 ms 4284 KB Output is correct
4 Correct 422 ms 4256 KB Output is correct
5 Correct 137 ms 2700 KB Output is correct
6 Correct 382 ms 4292 KB Output is correct
7 Correct 127 ms 2704 KB Output is correct
8 Correct 239 ms 3472 KB Output is correct
9 Correct 417 ms 4288 KB Output is correct
10 Correct 425 ms 4288 KB Output is correct
11 Correct 19 ms 1484 KB Output is correct
12 Correct 221 ms 3484 KB Output is correct
13 Correct 166 ms 3076 KB Output is correct
14 Correct 189 ms 3080 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 455 ms 4292 KB Output is correct
2 Correct 434 ms 4288 KB Output is correct
3 Correct 433 ms 4284 KB Output is correct
4 Correct 422 ms 4256 KB Output is correct
5 Correct 137 ms 2700 KB Output is correct
6 Correct 382 ms 4292 KB Output is correct
7 Correct 127 ms 2704 KB Output is correct
8 Correct 239 ms 3472 KB Output is correct
9 Correct 417 ms 4288 KB Output is correct
10 Correct 425 ms 4288 KB Output is correct
11 Correct 19 ms 1484 KB Output is correct
12 Correct 221 ms 3484 KB Output is correct
13 Correct 166 ms 3076 KB Output is correct
14 Correct 189 ms 3080 KB Output is correct
15 Correct 406 ms 4300 KB Output is correct
16 Correct 352 ms 4396 KB Output is correct
17 Correct 442 ms 4288 KB Output is correct
18 Correct 432 ms 4400 KB Output is correct
19 Correct 427 ms 4292 KB Output is correct
20 Correct 421 ms 4388 KB Output is correct
21 Correct 402 ms 4292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 716 KB Output is correct
2 Correct 1 ms 716 KB Output is correct
3 Correct 1 ms 716 KB Output is correct
4 Correct 1 ms 716 KB Output is correct
5 Correct 1 ms 716 KB Output is correct
6 Correct 1 ms 716 KB Output is correct
7 Correct 1 ms 716 KB Output is correct
8 Correct 1 ms 716 KB Output is correct
9 Correct 1 ms 716 KB Output is correct
10 Correct 1 ms 716 KB Output is correct
11 Correct 2 ms 844 KB Output is correct
12 Correct 1 ms 716 KB Output is correct
13 Correct 19 ms 1540 KB Output is correct
14 Correct 11 ms 1276 KB Output is correct
15 Correct 11 ms 1252 KB Output is correct
16 Correct 17 ms 1484 KB Output is correct
17 Correct 16 ms 1360 KB Output is correct
18 Correct 18 ms 1428 KB Output is correct
19 Correct 455 ms 4292 KB Output is correct
20 Correct 434 ms 4288 KB Output is correct
21 Correct 433 ms 4284 KB Output is correct
22 Correct 422 ms 4256 KB Output is correct
23 Correct 137 ms 2700 KB Output is correct
24 Correct 382 ms 4292 KB Output is correct
25 Correct 127 ms 2704 KB Output is correct
26 Correct 239 ms 3472 KB Output is correct
27 Correct 417 ms 4288 KB Output is correct
28 Correct 425 ms 4288 KB Output is correct
29 Correct 19 ms 1484 KB Output is correct
30 Correct 221 ms 3484 KB Output is correct
31 Correct 166 ms 3076 KB Output is correct
32 Correct 189 ms 3080 KB Output is correct
33 Correct 406 ms 4300 KB Output is correct
34 Correct 352 ms 4396 KB Output is correct
35 Correct 442 ms 4288 KB Output is correct
36 Correct 432 ms 4400 KB Output is correct
37 Correct 427 ms 4292 KB Output is correct
38 Correct 421 ms 4388 KB Output is correct
39 Correct 402 ms 4292 KB Output is correct
40 Correct 457 ms 5100 KB Output is correct
41 Correct 17 ms 1228 KB Output is correct
42 Correct 459 ms 5036 KB Output is correct
43 Correct 399 ms 4748 KB Output is correct
44 Correct 408 ms 4776 KB Output is correct
45 Correct 500 ms 8148 KB Output is correct
46 Correct 19 ms 1476 KB Output is correct
47 Correct 494 ms 8272 KB Output is correct
48 Correct 460 ms 6496 KB Output is correct
49 Correct 447 ms 7100 KB Output is correct