Submission #126005

#TimeUsernameProblemLanguageResultExecution timeMemory
126005HassoonyLottery (CEOI18_lot)C++17
100 / 100
814 ms8696 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int MX=10009; int n,l,a[MX],id[109]; pair<int,int> k[109]; int ans[MX][109]; int col[MX],p[MX]; int where[MX],ans1[MX][109],q; int main(){ cin>>n>>l; for(int i=1;i<=n;i++){ scanf("%d",&a[i]); } cin>>q; for(int i=1;i<=q;i++){ scanf("%d",&k[i].first); k[i].second=i; } for(int i=0;i<=l;i++)where[i]=q+1; sort(k+1,k+1+q); for(int i=1;i<=q;i++){ id[k[i].second]=i; } for(int i=0;i<=l;i++){ for(int j=1;j<=q;j++){ if(k[j].first>=i){ where[i]=j; break; } } } for(int j=1;j<=(n-l+1);j++){ for(int i=1;i<MX;i++)col[i]=p[i]=0; for(int i=1;i+j<=n;i++){ col[i]=(a[i]!=a[i+j]); p[i]=p[i-1]+col[i]; } for(int i=1;i+j+l-1<=n;i++){ ans[i][where[p[i+l-1]-p[i-1]]]++; ans[i+j][where[p[i+l-1]-p[i-1]]]++; } } for(int i=1;i<=n-l+1;i++){ for(int j=1;j<=q;j++){ ans[i][j]+=ans[i][j-1]; } } for(int i=1;i<=q;i++){ for(int j=1;j<=n-l+1;j++)cout<<ans[j][id[i]]<<" "; puts(""); } } /* 6 2 1 2 1 3 2 1 2 1 2 */

Compilation message (stderr)

lot.cpp: In function 'int main()':
lot.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&a[i]);
         ~~~~~^~~~~~~~~~~~
lot.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&k[i].first);
         ~~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...