Submission #5892204
Source Code Expand
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
static constexpr int mod = (int)1e9 + 7;
static constexpr int inf = 100100100;
static constexpr ll linf = 1e18;
static constexpr double eps = 1e-9;
static constexpr double pi = 3.14159265359;
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, n) for (ll i = n; i >= 0; --i)
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define pb push_back
#define ist insert
#define fst first
#define snd second
int main() {
// cin.tie(0);
// ios_base::sync_with_stdio(false);
ll N, Q;
cin >> N >> Q;
string S;
cin >> S;
vector<ll> V;
rep (i, N - 1) {
if (S[i] == 'A' && S[i + 1] == 'C') {
V.pb(i);
}
}
rep (i, Q) {
ll l, r;
cin >> l >> r;
--l;
--r;
auto lit = lower_bound(all(V), l);
auto rit = lower_bound(all(V), r) - 1;
if (lit != V.end()) {
cout << (rit - lit) + 1 << endl;
} else {
cout << 0 << endl;
}
}
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - GeT AC |
| User | gochiusa |
| Language | C++14 (Clang 3.8.0) |
| Score | 300 |
| Code Size | 1546 Byte |
| Status | AC |
| Exec Time | 417 ms |
| Memory | 1464 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 300 / 300 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | a01 |
| All | a01, b02, b03, b04, b05, b06, b07, b08, b09, b10, b11, b12 |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| a01 | AC | 9 ms | 888 KiB |
| b02 | AC | 1 ms | 256 KiB |
| b03 | AC | 362 ms | 1464 KiB |
| b04 | AC | 379 ms | 1464 KiB |
| b05 | AC | 410 ms | 1464 KiB |
| b06 | AC | 383 ms | 1464 KiB |
| b07 | AC | 377 ms | 1464 KiB |
| b08 | AC | 417 ms | 1464 KiB |
| b09 | AC | 412 ms | 1336 KiB |
| b10 | AC | 402 ms | 960 KiB |
| b11 | AC | 387 ms | 704 KiB |
| b12 | AC | 393 ms | 704 KiB |