Submission #63526

#TimeUsernameProblemLanguageResultExecution timeMemory
63526TalantElection (BOI18_election)C++17
28 / 100
3046 ms1176 KiB
#include <bits/stdc++.h> #define mk make_pair #define sc second #define fr first #define pb emplace_back #define all(s) s.begin(), s.end() #define sz(s) ( (int)s.size() ) #define Scan(a) scanf ("%I64d", &a) #define scan(a) scanf ("%d", &a) using namespace std; const int inf = (int)1e9 + 7; const int N = (int)5e5 + 7; int n; int q; int l,r; int u[N]; string a; vector <int> v; main () { cin >> n; cin >> a; cin >> q; while (q --) { int sum = 0,sum1 = 0,f = 0; cin >> l >> r; l --,r --; for (int i = l; i <= r; i ++) { if (a[i] == 'T' && f == 0) u[i] = 1; else if (a[i] == 'T' && f > 0) f --; else f ++; } f = 0; for (int i = r; i >= l; i --) { if (u[i] == 1) continue; if (a[i] == 'T' && f == 0) u[i] = 1; else if (a[i] == 'T' && f > 0) f --; else f ++; } for (int i = l; i <= r; i ++) sum += u[i],u[i] = 0; v.pb(sum); } for (auto to : v) cout << to << endl; }

Compilation message (stderr)

election.cpp:25:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main () {
       ^
election.cpp: In function 'int main()':
election.cpp:31:25: warning: unused variable 'sum1' [-Wunused-variable]
             int sum = 0,sum1 = 0,f = 0;
                         ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...