Submission #108421

#TimeUsernameProblemLanguageResultExecution timeMemory
108421win11905Election (BOI18_election)C++11
28 / 100
3025 ms2040 KiB
/** * code generated by JHelper * More info: https://github.com/AlexeyDmitriev/JHelper * @author win11905 */ #include <bits/stdc++.h> #define all(x) (x).begin(), (x).end() #define vi vector<int> #define iii tuple<int, int, int> #define long long long #define pii pair<int, int> #define x first #define y second using namespace std; const long MOD = 1e9+7, LINF = 1e18 + 1e16; const int INF = 1e9+1; const double EPS = 1e-10; const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1}; const int N = 5e5+5; class election { private: int n, m; char arr[N]; bool st[N]; public: void solve(istream& cin, ostream& cout) { cin >> n; cin >> arr+1; cin >> m; for(int i = 0, l, r; i < m; ++i) { cin >> l >> r; int cnt = 0; set<int> s; for(int i = l; i <= r; ++i) { cnt += arr[i] == 'C' ? 1 : -1; if(cnt < 0) s.emplace(i), cnt++; } cnt = 0; for(int i = r; i >= l; --i) { if(s.count(i)) continue; cnt += arr[i] == 'C' ? 1 : -1; if(cnt < 0) s.emplace(i), cnt++; } cout << s.size() << endl; } } }; class Solver { public: void solve(std::istream& in, std::ostream& out) { election *obj = new election(); obj->solve(in, out); } }; int32_t main() { ios::sync_with_stdio(false); cin.tie(0); Solver solver; std::istream& in(std::cin); std::ostream& out(std::cout); solver.solve(in, out); return 0; }

Compilation message (stderr)

election.cpp: In member function 'void election::solve(std::istream&, std::ostream&)':
election.cpp:31:19: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
         cin >> arr+1;
                ~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...