Submission #112420

#TimeUsernameProblemLanguageResultExecution timeMemory
112420SuperJumboLottery (CEOI18_lot)C++14
0 / 100
285 ms760 KiB
#include<bits/stdc++.h> using namespace std; int main(){ int n,l; scanf("%d %d",&n,&l); vector<int> a(n); for(int i = 0;i<n;i++)scanf("%d",&a[i]); int q;scanf("%d",&q); vector<int> queries; map<int,vector<int>> ans; for(int i = 0;i<q;i++){ int x;scanf("%d",&x); queries.push_back(x); ans[x] = vector<int> (n-l+1,0); } vector<int> v(n); vector<int> sum(n,0); for(int i = 0;i<n;i++){ int u = i - l; if(i>=l){ for(int j = u+1,x = 0;j<n;x++,j++) sum[x]-=(a[u] != a[j]); } for(int j = i+1,x = 0;j<n;x++,j++){ sum[x]+=(a[i] != a[j]); if(i>=l-1){ auto y = ans.lower_bound(sum[x]); if(y == ans.end())continue; ans[y->first][u+1]++; ans[y->first][u+2+x]++; } } } auto x = ans.begin(),y=x; y++; do{ for(int i = 0;i<n-l+1;i++) ans[y->first][i] += ans[x->first][i]; x = y++; }while(y!=ans.end()); for(auto u : queries){ for(auto v:ans[u]) printf("%d ",v); printf("\n"); } }

Compilation message (stderr)

lot.cpp: In function 'int main()':
lot.cpp:5:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n,&l);
  ~~~~~^~~~~~~~~~~~~~~
lot.cpp:7:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i = 0;i<n;i++)scanf("%d",&a[i]);
                        ~~~~~^~~~~~~~~~~~
lot.cpp:8:13: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int q;scanf("%d",&q);  
        ~~~~~^~~~~~~~~
lot.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int x;scanf("%d",&x);
         ~~~~~^~~~~~~~~
#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...