Submission #930476

#TimeUsernameProblemLanguageResultExecution timeMemory
930476RegulusLottery (CEOI18_lot)C++17
0 / 100
5 ms1124 KiB
#include <bits/stdc++.h> #define IO ios::sync_with_stdio(false);cin.tie(0); #define debug(x) cerr << #x << " = " << (x) << ' ' #define bug(x) cerr << (x) << ' ' #define endl cerr << '\n' #define all(v) (v).begin(), (v).end() #define SZ(v) (ll)(v).size() #define lowbit(x) (x)&-(x) #define pb emplace_back #define F first #define S second using namespace std; using ll = long long; using pll = pair<ll, ll>; //#define TEST const int N = 10005; const int MOD = 19993; const int MOD2 = 1e9+7; ll a[N], sum[N], p[N]; map<ll, int> mp; int main(void) { IO int n, i, Q, len; cin >> n >> len; for (i=1; i <= n; ++i) cin >> a[i]; cin >> Q; if (Q != 1) assert(0); cin >> i; if (i != 0) assert(0); for (i=1, p[0]=1; i <= n; ++i) p[i] = p[i-1] * MOD % MOD2; for (i=1; i <= n; ++i) sum[i] = (sum[i-1]*MOD % MOD2 + a[i]) % MOD2; for (i=len; i <= n; ++i) { ll tmp = (sum[i] - sum[i-len]*p[len]%MOD2 + MOD2) % MOD2; ++mp[tmp]; } for (i=len; i <= n; ++i) { ll tmp = (sum[i] - sum[i-len]*p[len]%MOD2 + MOD2) % MOD2; cout << mp[tmp] - 1 << ' '; } cout << '\n'; return 0; }
#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...