Submission #807510

#TimeUsernameProblemLanguageResultExecution timeMemory
807510Valaki2Lottery (CEOI18_lot)C++14
100 / 100
446 ms8256 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mp make_pair #define pii pair<int, int> #define fi first #define se second const int maxn = 10000; //!!!!! const int maxq = 100; int n, l, q; int v[1 + maxn]; int conv[1 + maxn]; int dp[1 + maxn]; int ans[1 + maxn][1 + maxq]; int qry[1 + maxq]; void solve() { cin >> n >> l; for(int i = 1; i <= n; i++) { cin >> v[i]; } cin >> q; for(int i = n; i >= 0; i--) { conv[i] = q + 1; } for(int i = 1; i <= q; i++) { cin >> qry[i]; conv[qry[i]] = i; } vector<pii> sorted; for(int i = n; i >= 0; i--) { if(conv[i] != q + 1) { sorted.pb(mp(i, conv[i])); } } sort(sorted.begin(), sorted.end()); for(int i = n - 1; i >= 0; i--) { if(conv[i] == q + 1) { conv[i] = conv[i + 1]; } } for(int offset = 1; offset <= n - l; offset++) { for(int i = 1; i <= offset; i++) { dp[i] = 0; } for(int i = 1 + offset; i <= n; i++) { dp[i] = dp[i - 1]; if(v[i] != v[i - offset]) { dp[i]++; } if(i - l + 1 - offset >= 1) { #define a (i - l + 1) #define b (i - l + 1 - offset) #define dist (dp[i] - dp[i - l]) ans[a][conv[dist]]++; ans[b][conv[dist]]++; } } } for(int i = 1; i <= n - l + 1; i++) { for(int j = 1; j < sorted.size(); j++) { if(sorted[j].fi != sorted[j - 1].fi) { ans[i][sorted[j].se] += ans[i][sorted[j - 1].se]; } } } for(int i = 1; i <= q; i++) { for(int j = 1; j <= n - l + 1; j++) { cout << ans[j][conv[qry[i]]] << " "; } cout << "\n"; } } signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); solve(); return 0; }

Compilation message (stderr)

lot.cpp: In function 'void solve()':
lot.cpp:65:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |         for(int j = 1; j < sorted.size(); j++) {
      |                        ~~^~~~~~~~~~~~~~~
#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...