Submission #721018

#TimeUsernameProblemLanguageResultExecution timeMemory
721018TimDeeElection (BOI18_election)C++17
28 / 100
3058 ms2240 KiB
// you're already the best // yay // _ // ^ ^ // // >(O_O)<___// // \ __ __ \ // \\ \\ \\\\ #include <bits/stdc++.h> using namespace std; //#pragma GCC optimize("O3","unroll-loops") //#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") using ll = long long; #define int long long //#define double long double #define forn(i,n) for(int i=0; i<(n); ++i) #define pb push_back #define pi pair<int,int> #define f first #define s second #define vii(a,n) vector<int> a(n); forn(i,n) cin>>a[i]; #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int inf = 1e18; const int mod = 998244353; void solve() { int n; cin>>n; string s; cin>>s; int m; cin>>m; while (m--) { int l,r; cin>>l>>r; vector<int> z(n,0); int x=0; int ans=0; for (int i=l-1; i<r; ++i) { x+=1-2*(s[i]=='T'); if (x<0) { z[i]=1; x-=1-2*(s[i]=='T'); ++ans; } } x=0; for (int i=r-1; i>=l-1; --i) { if (z[i]) continue; x+=1-2*(s[i]=='T'); if (x<0) { z[i]=1; x-=1-2*(s[i]=='T'); ++ans; } } cout<<ans<<'\n'; } } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t=1; //cin>>t; while (t--) solve(); return 0; }

Compilation message (stderr)

election.cpp:6:1: warning: multi-line comment [-Wcomment]
    6 | //   \ __ __  \
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...