Submission #528102

#TimeUsernameProblemLanguageResultExecution timeMemory
528102idasLottery (CEOI18_lot)C++11
100 / 100
1260 ms8248 KiB
#include <bits/stdc++.h> #define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr) #define FOR(i, begin, end) for(int i = (begin); i < (end); i++) #define TSTS int ttt; cin >> ttt; while(ttt--) solve() #define all(x) (x).begin(), (x).end() #define le(vec) vec[vec.size()-1] #define sz(x) ((int)((x).size())) #define pb push_back #define s second #define f first using namespace std; typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef map<int, int> mii; typedef pair<int, int> pii; typedef pair<long long, long long> pll; typedef pair<long double, long double> pdd; const int INF=1e9, MOD=1e9+7, mod=998244353; const ll LINF=1e18; void setIO() { FAST_IO; } void setIO(string s) { FAST_IO; freopen((s+".in").c_str(), "r", stdin); freopen((s+".out").c_str(), "w", stdout); } const int N=1e4+1, Q=101; int n, l, qr, a[N], c[N], q[Q], cn[N][Q], id; set<int> st; int main() { setIO(); cin >> n >> l; FOR(i, 0, n) cin >> a[i]; cin >> qr; FOR(i, 0, qr) { cin >> q[i]; st.insert(q[i]); } for(auto x : st) c[x]=id++; for(int d=1; d+l-1<n; d++) { int eq=0; FOR(in, 0, l) { if(a[in]==a[in+d]){ eq++; } } int dif=l-eq; auto it=st.lower_bound(dif); if(it!=st.end()){ int idx=c[*it]; cn[0][idx]++; cn[d][idx]++; } for(int i=1; i+d+l-1<n; i++) { int j=i+d, e=j+l-1, y=i+l-1; if(a[j-1]==a[i-1]){ eq--; } if(a[e]==a[y]){ eq++; } int dif=l-eq; auto it=st.lower_bound(dif); if(it!=st.end()){ int idx=c[*it]; cn[i][idx]++; cn[j][idx]++; } } } FOR(i, 1, id) { FOR(j, 0, n-l+1) { cn[j][i]+=cn[j][i-1]; } } FOR(i, 0, qr) { FOR(j, 0, n-l+1) { cout << cn[j][c[q[i]]] << " "; } cout << '\n'; } }

Compilation message (stderr)

lot.cpp: In function 'void setIO(std::string)':
lot.cpp:32:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |     freopen((s+".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lot.cpp:33:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |     freopen((s+".out").c_str(), "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...