# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
74127 | 2018-08-30T07:36:54 Z | haitun | Election (BOI18_election) | C++14 | 25 ms | 1400 KB |
#include <bits/stdc++.h> //#include "functions.h" #define FOR(x,y) for(int x = 0; x < y; x++) #define ALLR(x) x.begin(),x.end() #define con continue #define ll long long #define LINF LLONG_MAX #define INF INT_MAX #define pii pair<int,int> #define vi vector <int> #define pb push_back #define F first #define S second #define len(x) x.length() #define sz(x) x.size() #define SEE(v) for(auto x : v) cout << x << " "; cout << endl; using namespace std; int main(){ if(fopen("test.txt","r")) freopen("test.txt","r",stdin); int n; cin >> n; string s; cin >> s; int q; cin >> q; vector <pii> sc(q); FOR(j, q) cin >> sc[j].F >> sc[j].S; FOR(j, q) { int l = sc[j].F, r = sc[j].S; string ss = s.substr(l - 1, r - l + 1); cout << ss << endl; vector <bool> nulled(ss.length(), 0); int cnt1 = 0, cnt2 = 0, ans = 0; FOR(k, ss.length()) { if(ss[k] == 'C') cnt1++; else cnt2++; if(cnt2 > cnt1) { cnt2--; nulled[k] = true; } } cnt1 = cnt2 = 0; for(int k = ss.length() - 1; k >= 0; k--) { if(nulled[k]) con; if(ss[k] == 'C') cnt1++; else cnt2++; if(cnt2 > cnt1) { cnt2--; nulled[k] = true; } } FOR(k, nulled.size()) { if(nulled[k]) ans++; } cout << ans << endl; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 25 ms | 1400 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 25 ms | 1400 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 25 ms | 1400 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |