QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#186237 | #2164. Landscape Generator | So_Stuffy# | WA | 1ms | 3632kb | C++20 | 3.5kb | 2023-09-23 14:51:10 | 2023-09-23 14:51:10 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 500;
int D[8 * N], t[8 * N];
void push(int v, int l, int r) {
t[v] += D[v] * (r - l + 1);
D[v * 2] += D[v];
D[v * 2 + 1] += D[v];
D[v] = 0;
}
void upd(int v, int l, int r, int tl, int tr, int val) {
push(v, l, r);
if (l > r || tl > tr || l > tr || tl > r) {
return;
}
if (l >= tl && r <= tr) {
D[v] += val;
push(v, l, r);
return;
}
int md = (l + r) >> 1;
upd(v * 2, l, md, tl, tr, val);
upd(v * 2 + 1, md + 1, r, tl, tr, val);
t[v] = t[v * 2] + t[v * 2 + 1];
}
int get(int v, int l, int r, int tl, int tr) {
push(v, l, r);
if (l > r || tl > tr || l > tr || tl > r) {
return 0;
}
if (l >= tl && r <= tr) {
return t[v];
}
int md = (l + r) >> 1;
return get(v * 2, l, md, tl, tr) + get(v * 2 + 1, md + 1, r, tl, tr);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, q;
cin >> n >> q;
while (q--) {
int l, r;
char c;
cin >> c >> l >> r;
if (c == 'R') {
upd(1, 1, n, l, l, 1);
if (r + 1 <= n) {
upd(1, 1, n, r + 1, r + 1, -1);
}
} else {
if (c == 'D') {
upd(1, 1, n, l, l, -1);
if (r + 1 <= n) {
upd(1, 1, n, r + 1, r + 1, 1);
}
} else {
if (c == 'H') {
int md = (l + r) >> 1;
if (l == r) {
upd(1, 1, n, l, l, 1);
if (l + 1 <= n) {
upd(1, 1, n, l + 1, l + 1, -1);
}
}
if ((r - l) % 2 == 0) {
upd(1, 1, n, l, md, 1);
upd(1, 1, n, md + 1, r, -1);
if (r + 1 <= n) {
upd(1, 1, n, r + 1, r + 1, -1);
}
} else {
upd(1, 1, n, l, md, 1);
if (md + 2 <= r) {
upd(1, 1, n, md + 2, r, -1);
}
if (r + 1 <= n) {
upd(1, 1, n, r + 1, r + 1, -1);
}
}
} else {
int md = (l + r) >> 1;
if (l == r) {
upd(1, 1, n, l, l, -1);
if (l + 1 <= n) {
upd(1, 1, n, l + 1, l + 1, 1);
}
}
if ((r - l) % 2 == 0) {
upd(1, 1, n, l, md, -1);
upd(1, 1, n, md + 1, r, 1);
if (r + 1 <= n) {
upd(1, 1, n, r + 1, r + 1, 1);
}
} else {
upd(1, 1, n, l, md, -1);
if (md + 2 <= r) {
upd(1, 1, n, md + 2, r, 1);
}
if (r + 1 <= n) {
upd(1, 1, n, r + 1, r + 1, 1);
}
}
}
}
}
}
for (int i = 1; i <= n; i++) {
cout << get(1, 1, n, 1, i) << "\n";
}
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3632kb
input:
71 1487 H 20 68 D 22 52 H 39 55 V 8 58 V 56 61 V 1 30 V 3 11 V 40 49 H 4 24 H 27 68 H 28 36 R 7 30 V 4 42 V 9 24 D 7 15 R 2 31 V 29 51 R 9 11 V 69 69 R 65 70 H 2 56 V 21 22 D 23 35 H 23 47 D 59 60 D 16 50 V 3 26 V 64 70 H 28 31 R 24 25 H 4 70 D 1 42 D 39 39 D 11 33 V 16 68 H 53 71 V 2 71 H 26 47 H 5...
output:
-2 4 12 30 48 60 67 85 99 89 79 64 49 33 9 -12 -27 -20 -39 -54 -71 -85 -89 -85 -88 -97 -102 -100 -84 -63 -48 -26 -19 -20 -19 -12 5 23 37 48 61 77 96 105 106 106 99 79 65 59 57 49 46 35 28 22 16 19 14 8 6 9 12 10 1 -8 -13 -3 4 -5 2
result:
wrong answer 7th lines differ - expected: '68', found: '67'