답안 #504530

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
504530 2022-01-10T06:19:03 Z ToroTN Lottery (CEOI18_lot) C++14
100 / 100
831 ms 8280 KB
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
int n,a[10005],m,t,num[105],idx[10005],ans[105][10005],qs[10005];
vector<pair<int,int> > v;
int query(int l,int r)
{
    return qs[r]-qs[l-1];
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    scanf("%d",&t);
    for(int i=1;i<=t;i++)
    {
        scanf("%d",&num[i]);
        v.push_back({num[i],i});
    }
    sort(v.begin(),v.end());
    for(int i=0;i<v.size();i++)
    {
        idx[v[i].first]=i+1;
    }
    for(int i=10000;i>=1;i--)
    {
        if(i>v[v.size()-1].first)
        {
            idx[i]=v.size()+1;
        }else
        {
            if(idx[i]==0)
            {
                idx[i]=idx[i+1];
            }
        }
    }
    idx[0]=1;
    for(int i=-n;i<=n;i++)
    {
        if(i!=0)
        {
            for(int j=max(1-i,1);j<=min(n-i,n);j++)
            {
                if(a[j]!=a[j+i])
                {
                    qs[j]=1;
                }else
                {
                    qs[j]=0;
                }
                qs[j]+=qs[j-1];
            }
            for(int j=max(1-i,1);j<=min(n-i,n);j++)
            {
                if(j+i+m-1>=1&&j+i+m-1<=n&&j+m-1>=1&&j+m-1<=n)
                {
                    ++ans[idx[query(j,j+m-1)]][j];
                }
            }
        }
    }
    for(int i=1;i<=t;i++)
    {
        for(int j=1;j<=n-m+1;j++)
        {
            ans[i][j]+=ans[i-1][j];
        }
    }
    for(int i=1;i<=t;i++)
    {
        for(int j=1;j<=n-m+1;j++)
        {
            printf("%d ",ans[idx[num[i]]][j]);
        }
        printf("\n");
    }
}

Compilation message

lot.cpp: In function 'int main()':
lot.cpp:25:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for(int i=0;i<v.size();i++)
      |                 ~^~~~~~~~~
lot.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf("%d%d",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~
lot.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |         scanf("%d",&a[i]);
      |         ~~~~~^~~~~~~~~~~~
lot.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |     scanf("%d",&t);
      |     ~~~~~^~~~~~~~~
lot.cpp:21:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |         scanf("%d",&num[i]);
      |         ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 460 KB Output is correct
11 Correct 2 ms 460 KB Output is correct
12 Correct 2 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 460 KB Output is correct
11 Correct 2 ms 460 KB Output is correct
12 Correct 2 ms 460 KB Output is correct
13 Correct 30 ms 408 KB Output is correct
14 Correct 19 ms 496 KB Output is correct
15 Correct 20 ms 452 KB Output is correct
16 Correct 28 ms 580 KB Output is correct
17 Correct 26 ms 620 KB Output is correct
18 Correct 25 ms 580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 761 ms 476 KB Output is correct
2 Correct 725 ms 416 KB Output is correct
3 Correct 743 ms 532 KB Output is correct
4 Correct 714 ms 476 KB Output is correct
5 Correct 316 ms 520 KB Output is correct
6 Correct 721 ms 516 KB Output is correct
7 Correct 309 ms 420 KB Output is correct
8 Correct 456 ms 420 KB Output is correct
9 Correct 698 ms 476 KB Output is correct
10 Correct 714 ms 536 KB Output is correct
11 Correct 37 ms 380 KB Output is correct
12 Correct 427 ms 436 KB Output is correct
13 Correct 365 ms 424 KB Output is correct
14 Correct 385 ms 516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 761 ms 476 KB Output is correct
2 Correct 725 ms 416 KB Output is correct
3 Correct 743 ms 532 KB Output is correct
4 Correct 714 ms 476 KB Output is correct
5 Correct 316 ms 520 KB Output is correct
6 Correct 721 ms 516 KB Output is correct
7 Correct 309 ms 420 KB Output is correct
8 Correct 456 ms 420 KB Output is correct
9 Correct 698 ms 476 KB Output is correct
10 Correct 714 ms 536 KB Output is correct
11 Correct 37 ms 380 KB Output is correct
12 Correct 427 ms 436 KB Output is correct
13 Correct 365 ms 424 KB Output is correct
14 Correct 385 ms 516 KB Output is correct
15 Correct 719 ms 524 KB Output is correct
16 Correct 662 ms 420 KB Output is correct
17 Correct 749 ms 436 KB Output is correct
18 Correct 761 ms 584 KB Output is correct
19 Correct 740 ms 536 KB Output is correct
20 Correct 736 ms 476 KB Output is correct
21 Correct 746 ms 520 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 460 KB Output is correct
11 Correct 2 ms 460 KB Output is correct
12 Correct 2 ms 460 KB Output is correct
13 Correct 30 ms 408 KB Output is correct
14 Correct 19 ms 496 KB Output is correct
15 Correct 20 ms 452 KB Output is correct
16 Correct 28 ms 580 KB Output is correct
17 Correct 26 ms 620 KB Output is correct
18 Correct 25 ms 580 KB Output is correct
19 Correct 761 ms 476 KB Output is correct
20 Correct 725 ms 416 KB Output is correct
21 Correct 743 ms 532 KB Output is correct
22 Correct 714 ms 476 KB Output is correct
23 Correct 316 ms 520 KB Output is correct
24 Correct 721 ms 516 KB Output is correct
25 Correct 309 ms 420 KB Output is correct
26 Correct 456 ms 420 KB Output is correct
27 Correct 698 ms 476 KB Output is correct
28 Correct 714 ms 536 KB Output is correct
29 Correct 37 ms 380 KB Output is correct
30 Correct 427 ms 436 KB Output is correct
31 Correct 365 ms 424 KB Output is correct
32 Correct 385 ms 516 KB Output is correct
33 Correct 719 ms 524 KB Output is correct
34 Correct 662 ms 420 KB Output is correct
35 Correct 749 ms 436 KB Output is correct
36 Correct 761 ms 584 KB Output is correct
37 Correct 740 ms 536 KB Output is correct
38 Correct 736 ms 476 KB Output is correct
39 Correct 746 ms 520 KB Output is correct
40 Correct 769 ms 2008 KB Output is correct
41 Correct 172 ms 840 KB Output is correct
42 Correct 752 ms 1988 KB Output is correct
43 Correct 739 ms 1608 KB Output is correct
44 Correct 718 ms 1628 KB Output is correct
45 Correct 831 ms 8220 KB Output is correct
46 Correct 181 ms 1440 KB Output is correct
47 Correct 824 ms 8280 KB Output is correct
48 Correct 789 ms 6532 KB Output is correct
49 Correct 763 ms 7092 KB Output is correct