Submission #261169

#TimeUsernameProblemLanguageResultExecution timeMemory
261169sjimedLottery (CEOI18_lot)C++14
0 / 100
572 ms476 KiB
#include<bits/stdc++.h> using namespace std; #define fast ios::sync_with_stdio(false);cin.tie(NULL) #define fi first #define se second #define all(v) (v).begin(),(v).end() #define pb push_back #define eb emplace_back #define em emplace #define pre(a) cout<<fixed; cout.precision(a) #define mp make_pair typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; const ll INF = 1e18; const int inf = 1e9; int n, l, q; int a[10010]; int k[111]; int g[10010]; int ans[10010][111]; int main() { fast; cin >> n >> l; for(int i=1; i<=n; i++) { cin >> a[i]; } cin >> q; vector<int> v; for(int i=1; i<=q; i++) { cin >> k[i]; v.eb(k[i]); } v.eb(-1); v.eb(l); sort(all(v)); v.erase(unique(all(v)), v.end()); for(int i=1; i<v.size(); i++) { for(int j=v[i-1]+1; j<=v[i]; j++) g[j] = i; } for(int i=1; i+l<=n; i++) { int cnt = 0; for(int j=1; j<=l; j++) { if(a[j] != a[j+i]) cnt++; } for(int j=1; j+i <= n-l+1; j++) { ans[g[cnt]][j]++; ans[g[cnt]][j+i]++; if(a[j+i] != a[j]) cnt--; if(a[j+l+i] != a[j+l]) cnt++; } } for(int i=1; i<=q; i++) { for(int j=1; j<=n-l+1; j++) { ans[i][j] += ans[i-1][j]; } } for(int i=1; i<=q; i++) { for(int j=1; j<=n-l+1; j++) { cout << ans[g[k[i]]][j] << " "; } cout << "\n"; } }

Compilation message (stderr)

lot.cpp: In function 'int main()':
lot.cpp:49:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=1; i<v.size(); i++) {
               ~^~~~~~~~~
#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...