Submission #868125

#TimeUsernameProblemLanguageResultExecution timeMemory
868125CookieLottery (CEOI18_lot)C++14
35 / 100
1037 ms848 KiB
#include<bits/stdc++.h> #include<fstream> using namespace std; ifstream fin("HCN.INP"); ofstream fout("HCN.OUT"); #define sz(a) (int)a.size() #define ll long long #define pb push_back #define forr(i, a, b) for(int i = a; i < b; i++) #define dorr(i, a, b) for(int i = a; i >= b; i--) #define ld long double #define vt vector #include<fstream> #define fi first #define se second #define pll pair<ll, ll> #define pii pair<int, int> const ld PI = 3.14159265359; //using u128 = __uint128_t; //const int x[4] = {1, -1, 0, 0}; //const int y[4] = {0, 0, 1, -1}; const ll mod = 1e9 + 9; const int mxn = 1e5 + 5, mxq = 2e5 + 5, sq = 200, mxv = 2e6 + 5; const ll inf = 1e17 + 5; //const int base= (1 << 18); mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); int n, l; int a[10005], ans[10005], res = 0, ok = 0; void add(int diag, int row){ int col = diag - n + row; if(col >= 1 && col <= n){ ok++; res += (a[row] != a[col]); } } void rem(int diag, int row){ int col = diag - n + row; if(col >= 1 && col <= n){ ok--; res -= (a[row] != a[col]); } } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> l; for(int i = 1; i <= n; i++)cin >> a[i]; int q, k; cin >> q >> k; for(int i = 1; i <= n + n - 1; i++){ res = ok = 0; if(i == n)continue; for(int j = 1; j <= l; j++)add(i, j); if(ok == l && res <= k){ ans[1]++; } for(int j = 2; j + l - 1 <= n; j++){ rem(i, j - 1); add(i, j + l - 1); if(ok == l && res <= k){ ans[j]++; } } } for(int i = 1; i + l - 1 <= n; i++)cout << ans[i] << " "; 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...