Submission #885613

#TimeUsernameProblemLanguageResultExecution timeMemory
885613shenfe1Lottery (CEOI18_lot)C++14
100 / 100
554 ms21080 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define pb push_back #define pf push_front #define pii pair<int,int> #define all(v) v.begin(),v.end() #define F first #define S second #define mem(a,i) memset(a,i,sizeof(a)) #define sz(s) (int)s.size() #define int ll // #define int short int #define y1 yy #define ppb pop_back #define lb lower_bound #define ub upper_bound #define gcd(a,b) __gcd(a,b) #define in insert #define pdd pair<ld,ld> const int MAX=1e4+10; int dx[4]={1,0,-1,0}; int dy[4]={0,1,0,-1}; mt19937 rng; int n,l,q; int a[MAX]; int c[MAX][105]; int ans[105][MAX]; pii k[MAX]; int r[MAX]; void solve(){ cin>>n>>l; for(int i=1;i<=n;i++){ cin>>a[i]; } cin>>q; for(int i=1;i<=q;i++){ cin>>k[i].F; k[i].S=i; } sort(k+1,k+q+1); int pos=1; for(int i=1;i<=l;i++){ while(pos+1<=q&&i>k[pos].F){ pos++; } if(pos==q&&i>k[pos].F)r[i]=q+1; else r[i]=pos; } for(int dif=1;dif+l<=n;dif++){ int i=1,j=dif+1; int cnt=0; for(int k=0;k<l;k++){ if(a[i+k]!=a[j+k]){ cnt++; } } c[i][r[cnt]]++;c[j][r[cnt]]++; i+=l;j+=l; while(j<=n){ if(a[i]!=a[j])cnt++; if(a[i-l]!=a[j-l])cnt--; c[i-l+1][r[cnt]]++;c[j-l+1][r[cnt]]++; i++,j++; } } for(int i=1;i<=n-l+1;i++){ for(int j=1;j<=q;j++){ c[i][j]+=c[i][j-1]; ans[k[j].S][i]=c[i][j]; } } for(int i=1;i<=q;i++){ for(int j=1;j<=n-l+1;j++){ cout<<ans[i][j]<<" "; } cout<<"\n"; } } main(){ // freopen("color.in", "r", stdin); // freopen("color.out", "w", stdout); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t=1; // cin>>t; while(t--){ solve(); } }

Compilation message (stderr)

lot.cpp:90:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   90 | main(){
      | ^~~~
#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...