Submission #397964

#TimeUsernameProblemLanguageResultExecution timeMemory
397964VictorLottery (CEOI18_lot)C++17
45 / 100
363 ms65540 KiB
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i = a; i < (b); ++i) #define per(i, a, b) for (int i = b - 1; i >= (a); --i) #define trav(a, x) for (auto &a : x) #define all(x) x.begin(), x.end() #define sz(x) x.size() #define pb push_back #define umap unordered_map #define uset unordered_set typedef pair<int, int> ii; typedef pair<int, ii> iii; typedef vector<int> vi; typedef vector<ii> vii; typedef vector<vi> vvi; typedef long long ll; const int INF = 1000000007; int main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); ushort n, l, q, mismatch[10001], groups, queryval[101]; int arr[10001]; cin >> n >> l; groups = n - l + 1; rep(i, 0, n) cin >> arr[i]; vector<ushort> diffs[10001]; cin >> q; set<ushort> queries; queries.insert(l + 1); int diff; rep(i, 0, q) { cin >> queryval[i]; queries.insert(queryval[i]); } memset(mismatch, 0, sizeof(mismatch)); rep(i, 0, l) rep(j, i + 1, groups + i) if (arr[i] != arr[j])++ mismatch[j - i]; rep(i, 0, groups) { rep(j, 1, groups - i) { int val = *queries.lower_bound(mismatch[j]); diffs[i].pb(val); diffs[j+i].pb(val); } rep(j, i + 1, min(int(n), groups + i)) if (arr[i] != arr[j])-- mismatch[j - i]; rep(j, i + l + 1, n) if (arr[i + l] != arr[j])++ mismatch[j - i - l]; } rep(i,0,q){ diff=queryval[i]; rep(j,0,groups){ ushort ans=0; trav(val,diffs[j])if(val<=diff)++ans; cout<<ans<<' '; } cout<<endl; } 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...