QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#32864 | #884. Joining Treasure Hunt | AutumnKite | RE | 3ms | 4532kb | C++17 | 1.3kb | 2022-05-25 10:16:02 | 2022-05-25 10:16:02 |
Judging History
answer
#include <bits/stdc++.h>
const char name[] = "nsew";
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int n, m;
std::cin >> n >> m;
std::vector<int> a(n);
for (int i = 0; i < n; ++i) {
char c;
std::cin >> c;
if (c == '?') {
a[i] = -1;
} else {
int x;
std::cin >> x;
assert(n != 400000 || (c == 'e' && x == 7));
a[i] = (std::find(name, name + 4, c) - name) * 4 + x - 1;
}
}
std::vector<int> b(m);
for (int i = 0; i < m; ++i) {
char c;
std::cin >> c;
if (c == '?') {
b[i] = -1;
} else {
int x;
std::cin >> x;
assert(n != 400000 || (c == 'e' && x == 7));
b[i] = (std::find(name, name + 4, c) - name) * 4 + x - 1;
}
}
const int C = 28;
std::vector<std::bitset<400000>> mask(C);
for (int i = 0; i < C; ++i) {
mask[i].set();
}
for (int i = 0; i < m; ++i) {
if (b[i] != -1) {
mask[b[i]].reset(i);
} else {
for (int j = 0; j < C; ++j) {
mask[j].reset(i);
}
}
}
std::bitset<400000> S;
S.set();
int ans = 0;
for (int i = 0; i < n; ++i) {
S <<= 1;
if (a[i] != -1) {
S |= mask[a[i]];
}
if (!S.test(m - 1)) {
++ans;
}
}
std::cout << ans << "\n";
}
詳細信息
Test #1:
score: 100
Accepted
time: 3ms
memory: 4512kb
input:
4 3 n 4 e 1 ? s 5 ? e 1 ?
output:
2
result:
ok answer is '2'
Test #2:
score: 0
Accepted
time: 3ms
memory: 4532kb
input:
4 3 n 4 e 1 w 3 s 5 ? e 1 ?
output:
1
result:
ok answer is '1'
Test #3:
score: -100
Dangerous Syscalls
input:
400000 200000 ? ? e 7 e 7 ? ? ? e 7 e 7 ? ? e 7 ? e 7 e 7 ? e 7 ? ? ? e 7 ? ? e 7 ? ? ? ? e 7 ? e 7 ? ? e 7 ? ? e 7 e 7 e 7 ? ? ? ? ? ? e 7 ? e 7 ? ? ? ? ? ? ? ? ? ? e 7 e 7 ? ? e 7 ? e 7 e 7 ? ? e 7 e 7 e 7 ? e 7 e 7 ? ? ? ? ? ? e 7 e 7 ? ? e 7 ? ? ? ? e 7 ? ? ? e 7 ? e 7 ? e 7 ? ? ? ? ? e 7 ? ? ? ...