| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1333664 | nguyengiabach1201 | Election (BOI18_election) | C++20 | 3091 ms | 640 KiB |
// https://oj.uz/problem/view/BOI18_election
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define el '\n'
#define FNAME ""
#define ll long long
#define int long long
#define ld long double
const int MOD = 1e9 + 7;
const ll INF = 1e18 + 7;
const double EPS = 1e-9;
void setup()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
if (fopen(FNAME ".inp", "r"))
{
freopen(FNAME ".inp", "r", stdin);
freopen(FNAME ".out", "w", stdout);
}
return;
}
int n, q;
string s;
void solve()
{
cin >> n >> s >> q, s = " " + s;
for (int l, r, i = 1; i <= q; ++i)
{
cin >> l >> r;
set<int> nullIdx;
int cCnt = 0, tCnt = 0;
for (int i = l; i <= r; ++i)
{
if (nullIdx.count(i))
continue;
if (s[i] == 'C')
++cCnt;
else
{
if (tCnt >= cCnt)
nullIdx.insert(i);
else
++tCnt;
}
}
cCnt = tCnt = 0;
for (int i = r; i >= l; --i)
{
if (nullIdx.count(i))
continue;
if (s[i] == 'C')
++cCnt;
else
{
if (tCnt >= cCnt)
nullIdx.insert(i);
else
++tCnt;
}
}
// for (int i : nullIdx)
// cerr << i << " ";
// cerr << el;
cout << nullIdx.size() << el;
}
return;
}
signed main()
{
setup();
int t = 1;
bool multiTest = false;
if (multiTest)
cin >> t;
while (t--)
solve();
return 0;
}컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
