제출 #1127107

#제출 시각아이디문제언어결과실행 시간메모리
1127107TrieTrLottery (CEOI18_lot)C++20
100 / 100
318 ms8508 KiB
#include<bits/stdc++.h> using namespace std; void local() { #define taskname "" if (fopen(taskname".inp", "r")) { freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } } #define ll long long #define fi first #define se second #define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); template<class X, class Y> bool mini(X &a, const Y &b) {return (a > b) ? a = b, true : false;} template<class X, class Y> bool maxi(X &a, const Y &b) {return (a < b) ? a = b, true : false;} const int N = 1e4 + 5; const int Q = 1e2 + 5; int n, l, q, a[N], que[N]; int cnt[N << 1], pf[N], diff[N]; int ans[N][Q]; void update(int id, int v) { for(int i = 1; i <= n; i++) cnt[i - id + N] += (a[i] != a[id]) * v; } int main() { fastio; local(); cin >> n >> l; int lim = n - l + 1; for(int i = 1; i <= n; i++) cin >> a[i]; cin >> q; for(int i = 1; i <= q; i++) cin >> que[i]; for(int i = 1, le = 1, ri = 1; i <= lim; i++) { while(ri < i + l) update(ri++, 1); while(le < i) update(le++, -1); memset(pf, 0, sizeof(pf)); for(int j = 1; j <= lim; j++) pf[cnt[j - i + N]]++; for(int j = 1; j <= l; j++) pf[j] += pf[j - 1]; for(int j = 1; j <= q; j++) ans[i][j] = pf[que[j]] - 1; } for(int i = 1; i <= q; i++) for(int j = 1; j <= lim; j++) cout << ans[j][i] << " \n"[j == lim]; }

컴파일 시 표준 에러 (stderr) 메시지

lot.cpp: In function 'void local()':
lot.cpp:7:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |         freopen(taskname".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
lot.cpp:8:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |         freopen(taskname".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...