Submission #397987

#TimeUsernameProblemLanguageResultExecution timeMemory
397987VictorLottery (CEOI18_lot)C++17
100 / 100
2383 ms8668 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); int n, l, q, mismatch[10003], groups, queryval[101], valtoidx[10003]; int arr[10003]; cin >> n >> l; groups = n - l + 1; rep(i, 0, n) cin >> arr[i]; cin >> q; vector<int> queries; queries.pb(l + 1); rep(i, 0, q) { cin >> queryval[i]; queries.pb(queryval[i]); } sort(all(queries)); queries.erase(unique(all(queries)), queries.end()); rep(i, 0, sz(queries)) valtoidx[queries[i]] = i; vvi ans(groups,vi(sz(queries))); 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 = *lower_bound(all(queries), mismatch[j]); int idx = valtoidx[val]; ++ans[i][idx]; ++ans[j + i][idx]; } 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,groups)rep(j,1,sz(queries))ans[i][j]+=ans[i][j-1]; rep(i, 0, q) { int idx = valtoidx[queryval[i]]; rep(j, 0, groups) cout << ans[j][idx] << ' '; cout << "\n"; } return 0; }

Compilation message (stderr)

lot.cpp: In function 'int main()':
lot.cpp:5:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define rep(i, a, b) for (int i = a; i < (b); ++i)
      |                                        ^
lot.cpp:47:5: note: in expansion of macro 'rep'
   47 |     rep(i, 0, sz(queries)) valtoidx[queries[i]] = i;
      |     ^~~
lot.cpp:5:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define rep(i, a, b) for (int i = a; i < (b); ++i)
      |                                        ^
lot.cpp:69:20: note: in expansion of macro 'rep'
   69 |     rep(i,0,groups)rep(j,1,sz(queries))ans[i][j]+=ans[i][j-1];
      |                    ^~~
#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...