Submission #116167

#TimeUsernameProblemLanguageResultExecution timeMemory
116167JohnTitorLottery (CEOI18_lot)C++11
0 / 100
573 ms4360 KiB
#include <bits/stdc++.h> using namespace std; #define FOR(i, j, k) for(int i=(j); i<=(k); i++) #define FFOR(i, j, k) for(int i=(j); i<(k); i++) #define DFOR(i, j, k) for(int i=(j); i>=(k); i--) #define bug(x) cerr<<#x<<" = "<<(x)<<'\n' #define pb push_back #define mp make_pair #define bit(s, i) (((s)>>(i))&1LL) #define mask(i) ((1LL<<(i))) #define builtin_popcount __builtin_popcountll #define __builtin_popcount __builtin_popcountll using ll=long long; using ld=long double; mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); const ld pi=acos(0)*2; template <typename T> inline void read(T &x){char c; bool nega=0; while((!isdigit(c=getchar()))&&(c!='-')); if(c=='-'){nega=1; c=getchar();} x=c-48; while(isdigit(c=getchar())) x=x*10+c-48; if(nega) x=-x;} template <typename T> inline void writep(T x){if(x>9) writep(x/10); putchar(x%10+48);} template <typename T> inline void write(T x){if(x<0){ putchar('-'); x=-x;} writep(x);} template <typename T> inline void writeln(T x){write(x); putchar('\n');} #define taskname "Lottery" int n, l, q; int a[10001]; int to[10001]; int ans[10001][101]; int r[101]; pair <int, int> k[101]; int main(){ #ifdef Aria if(fopen(taskname".in", "r")) freopen(taskname".in", "r", stdin); #endif // Aria read(n); read(l); FOR(i, 1, n) read(a[i]); read(q); FOR(i, 1, q){ read(k[i].first); k[i].second=i; } sort(k+1, k+q+1); DFOR(i, q, 1){ r[k[i].second]=i; FOR(j, 0, k[i].first) to[j]=i; } FOR(d, 1, n){ if(d+l>n) break; int sum=0; FFOR(i, 1, l) sum+=(a[i]!=a[i+d]); FOR(i, l, n){ if(i+d>n) break; // sum+=(a[i]!=a[i+d]); int sum=0; FFOR(j, 0, l) sum+=a[i-j]!=a[i+d-j]; ans[i][to[sum]]++; ans[i+d][to[sum]]++; // sum-=(a[i-l+1]!=a[i-l+1+d]); } } FOR(i, 1, n) FOR(j, 1, q) ans[i][j]+=ans[i][j-1]; sort(k+1, k+q+1, [](pair <int, int> A, pair <int, int> B){ return A.second<B.second; }); FOR(i, 1, q) FOR(j, l, n) write(ans[j][r[k[i].second]]), putchar(" \n"[j==n]); }
#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...