Submission #112403

#TimeUsernameProblemLanguageResultExecution timeMemory
112403SuperJumboLottery (CEOI18_lot)C++14
45 / 100
3088 ms632 KiB
#include<bits/stdc++.h> #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") 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[l-x] = vector<int> (n-l+1,1); } vector<int> v(n); vector<int> sum(n,0),first(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){ for(auto y:ans){ if(l-y.first<sum[x])break; ans[y.first][u+1]++; ans[y.first][u+2+x]++; } } } } for(auto u : queries){ for(auto v:ans[l-u]) printf("%d ",v-1); printf("\n"); } }

Compilation message (stderr)

lot.cpp:2:0: warning: ignoring #pragma comment  [-Wunknown-pragmas]
 #pragma comment(linker, "/stack:200000000")
 
lot.cpp: In function 'int main()':
lot.cpp:8: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:10: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:11: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:15: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...