답안 #941283

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
941283 2024-03-08T12:35:03 Z sleepntsheep Lottery (CEOI18_lot) C
25 / 100
31 ms 65536 KB
#include<stdio.h>

#define N 10001
int n,l,q,a[N];
short ans[N][N];
short dp[N*(N+1)/2];

int pos(int x,int y)
{
    return (y+1ll)*(y+2)/2+x;
}

int main()
{
    scanf("%d%d",&n,&l);
    for(int i=1;i<=n;++i)scanf("%d",a+i);
    for(int i=1;i<=n;++i)for(int j=i+1;j<=n;++j)dp[pos(i,j)]=(a[i]!=a[j]);
    for(int i=1;i<=n;++i)for(int j=i+1;j<=n;++j)dp[pos(i,j)]+=dp[pos(i-1,j-1)];

    for(int i=1;i+l-1<=n;++i)for(int j=i+1;j+l-1<=n;++j)
    {
        int d=dp[pos(i+l-1,j+l-1)]-dp[pos(i-1,j-1)];
        ans[i][d]++;
        ans[j][d]++;
    }
    for(int i=1;i<=n;++i)for(int j=1;j<=n;++j)ans[i][j]+=ans[i][j-1];
    scanf("%d",&q);
    for(int u;q--;)
    {
        scanf("%d",&u);
        for(int i=1;i+l-1<=n;++i)printf("%d ",ans[i][u]);
        puts("");
    }
}

Compilation message

lot.c: In function 'main':
lot.c:15:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     scanf("%d%d",&n,&l);
      |     ^~~~~~~~~~~~~~~~~~~
lot.c:16:26: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     for(int i=1;i<=n;++i)scanf("%d",a+i);
      |                          ^~~~~~~~~~~~~~~
lot.c:27:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     scanf("%d",&q);
      |     ^~~~~~~~~~~~~~
lot.c:30:9: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |         scanf("%d",&u);
      |         ^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 4956 KB Output is correct
9 Correct 1 ms 4956 KB Output is correct
10 Correct 2 ms 6692 KB Output is correct
11 Correct 2 ms 6492 KB Output is correct
12 Correct 2 ms 6488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 4956 KB Output is correct
9 Correct 1 ms 4956 KB Output is correct
10 Correct 2 ms 6692 KB Output is correct
11 Correct 2 ms 6492 KB Output is correct
12 Correct 2 ms 6488 KB Output is correct
13 Runtime error 31 ms 46684 KB Memory limit exceeded
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 11 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 11 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 4956 KB Output is correct
9 Correct 1 ms 4956 KB Output is correct
10 Correct 2 ms 6692 KB Output is correct
11 Correct 2 ms 6492 KB Output is correct
12 Correct 2 ms 6488 KB Output is correct
13 Runtime error 31 ms 46684 KB Memory limit exceeded
14 Halted 0 ms 0 KB -