Submission #870362

#TimeUsernameProblemLanguageResultExecution timeMemory
870362AloraElection (BOI18_election)C++17
28 / 100
3063 ms1408 KiB
#include <bits/stdc++.h> #define Alora "cownav" #define fi(i,a,b) for(int i = a; i <= b; i++) #define fid(i,a,b) for(int i = a; i >= b; i--) #define ll long long #define f first #define se second #define pii pair<int, int> #define getbit(i, j) ((i >> j) & 1) #define all(v) v.begin(), v.end() #define pb push_back #define maxn 300005 const int M = 1e9 + 7; using namespace std; int n, q, xd[maxn]; string s; int main(){ ios_base::sync_with_stdio(0); cin.tie(NULL); if(fopen(Alora".inp","r")){ freopen(Alora".inp","r",stdin); freopen(Alora".out","w",stdout);} cin >> n >> s; s = ' ' + s; cin >> q; while(q--){ int l, r; cin >> l >> r; fi(i, 1, n) xd[i] = 0; int c = 0, t = 0; fi(i, l, r){ if(s[i] == 'C') c++; else{ if(t < c) t++; else xd[i] = 1; } } c = t = 0; fid(i, r, l){ if(s[i] == 'C') c++; else if(xd[i] == 0){ if(t < c) t++; else xd[i] = 1; } } int ans = 0; fi(i, 1, n) ans += xd[i]; cout << ans << '\n'; } return 0; }

Compilation message (stderr)

election.cpp: In function 'int main()':
election.cpp:22:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |     freopen(Alora".inp","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
election.cpp:23:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |     freopen(Alora".out","w",stdout);}
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...