Contest Duration: ~ (local time) (120 minutes)

Submission #3660689

Source Code Expand

Copy
```#include <iostream>
#include <vector>
#include <utility>
#include <numeric>
#include <functional>
#include <stdio.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <deque>
#include <queue>
#include <map>
#include <chrono>
using namespace std;

int main() {
int N;
cin >> N;
string s;
cin >> s;
int Q;
cin >> Q;
vector<int> vk;
vector<int> va;
for (int i = 0; i != Q; ++i) {
int k;
cin >> k;
vk.push_back(k-1);
va.push_back(0);
}
for (int i = 0; i != Q; ++i) {
int d = 0, m = 0, dm = 0;
for (int j = 0; j != vk[i]; ++j) {
if (s[j] == 'D') ++d;
if (s[j] == 'M') {
++m;
dm += d;
}
if (s[j] == 'C') va[i] += dm;
}
for (int j = 0; j + vk[i] < N; ++j) {
if (s[j + vk[i]] == 'C') {
va[i] += dm;
}
if (s[j] == 'D') {
--d;
dm -= m;
}
if (s[j] == 'M') --m;
if (s[j + vk[i]] == 'D') ++d;
if (s[j + vk[i]] == 'M') {
++m;
dm += d;
}
}
}
for (auto a : va) {
cout << a << endl;
}
return 0;
}
```

#### Submission Info

Submission Time 2018-11-24 23:45:54+0900 C - k-DMC taku0728 C++14 (GCC 5.4.1) 0 1056 Byte WA 873 ms 1412 KB

#### Judge Result

Set Name Score / Max Score Test Cases
All 0 / 600 dmc-dmc-00, dmc-dmc-01, dmc-dmc-02, dmc-dmc-03, dmc-dmc-04, dmc-large-00, dmc-large-01, dmc-large-02, dmc-large-03, dmc-large-04, dmc-random-00, dmc-random-01, dmc-random-02, dmc-random-03, dmc-random-04, dmc-special-00, dmc-special-01, dmc-special-02, dmc-special-03, sample_01, sample_02, sample_03, sample_04
Case Name Status Exec Time Memory
dmc-dmc-00 828 ms 1412 KB
dmc-dmc-01 858 ms 1412 KB
dmc-dmc-02 811 ms 1412 KB
dmc-dmc-03 841 ms 1412 KB
dmc-dmc-04 873 ms 1412 KB
dmc-large-00 287 ms 1412 KB
dmc-large-01 290 ms 1412 KB
dmc-large-02 293 ms 1412 KB
dmc-large-03 282 ms 1412 KB
dmc-large-04 292 ms 1412 KB
dmc-random-00 252 ms 1412 KB
dmc-random-01 203 ms 1412 KB
dmc-random-02 166 ms 1412 KB
dmc-random-03 138 ms 1412 KB
dmc-random-04 109 ms 1412 KB
dmc-special-00 236 ms 1412 KB
dmc-special-01 267 ms 1412 KB
dmc-special-02 239 ms 1412 KB
dmc-special-03 226 ms 1412 KB
sample_01 1 ms 256 KB
sample_02 1 ms 256 KB
sample_03 1 ms 256 KB
sample_04 1 ms 256 KB