# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
757780 |
2023-06-13T18:22:58 Z |
taher |
Nautilus (BOI19_nautilus) |
C++17 |
|
493 ms |
2240 KB |
#include <bits/stdc++.h>
using namespace std;
const int Maxn = 500 + 1;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int r , c , m;
cin >> r >> c >> m;
vector<vector<char>> g(r , vector<char> (c));
for (int i = 0 ; i < r ; i++) {
for (int j = 0 ; j < c ; j++) {
cin >> g[i][j];
}
}
string s;
cin >> s;
vector<bitset<Maxn>> cur(r) , forbidden(r);
bitset<Maxn> Fixer;
for (int i = 0 ; i < c ; i++) {
Fixer[i] = 1;
}
auto Move_Up = [&]() {
vector<bitset<Maxn>> res(r);
for (int i = 0 ; i < r - 1 ; i++) {
res[i] |= cur[i + 1];
}
vector<bitset<Maxn>> t = res;
for (int i = 0 ; i < r ; i++) {
t[i] ^= forbidden[i];
}
for (int i = 0 ; i < r ; i++) {
res[i] &= t[i];
}
return res;
};
auto Move_Down = [&]() {
vector<bitset<Maxn>> res(r);
for (int i = 1 ; i < r ; i++) {
res[i] |= cur[i - 1];
}
vector<bitset<Maxn>> t = res;
for (int i = 0 ; i < r ; i++) {
t[i] ^= forbidden[i];
}
for (int i = 0 ; i < r ; i++) {
res[i] &= t[i];
}
return res;
};
auto Move_Left = [&]() {
vector<bitset<Maxn>> res(r);
for (int i = 0 ; i < r ; i++) {
res[i] = (cur[i] >> 1);
}
vector<bitset<Maxn>> t = res;
for (int i = 0 ; i < r ; i++) {
t[i] ^= forbidden[i];
}
for (int i = 0 ; i < r ; i++) {
res[i] &= t[i];
}
return res;
};
auto Move_Right = [&]() {
vector<bitset<Maxn>> res(r);
for (int i = 0 ; i < r ; i++) {
res[i] = (cur[i] << 1);
}
vector<bitset<Maxn>> t = res;
for (int i = 0 ; i < r ; i++) {
t[i] ^= forbidden[i];
}
for (int i = 0 ; i < r ; i++) {
res[i] &= t[i];
}
return res;
};
auto Fix = [&]() {
for (int i = 0 ; i < r ; i++) {
cur[i] &= Fixer;
}
return ;
};
for (int i = 0 ; i < r ; i++) {
for (int j = 0 ; j < c ; j++) {
if (g[i][j] != '#') cur[i][j] = true;
else forbidden[i][j] = true;
}
}
for (int idx = 0 ; idx < m ; idx++) {
vector<bitset<Maxn>> res(r);
if (s[idx] == 'N') {
res = Move_Up();
}
else if (s[idx] == 'S') {
res = Move_Down();
}
else if (s[idx] == 'E') {
res = Move_Right();
}
else if (s[idx] == 'W') {
res = Move_Left();
}
else {
vector<bitset<Maxn>> A = Move_Down();
vector<bitset<Maxn>> B = Move_Left();
vector<bitset<Maxn>> C = Move_Right();
vector<bitset<Maxn>> D = Move_Up();
for (int i = 0 ; i < r ; i++) {
res[i] |= A[i];
res[i] |= B[i];
res[i] |= C[i];
res[i] |= D[i];
}
}
swap(cur , res);
Fix();
}
int ans = 0;
for (int i = 0 ; i < r ; i++) {
for (int j = 0 ; j < c ; j++) {
if (cur[i][j]) {
assert(g[i][j] != '#');
ans += 1;
}
}
}
cout << ans << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
324 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
324 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
340 KB |
Output is correct |
7 |
Correct |
2 ms |
328 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
2 ms |
324 KB |
Output is correct |
10 |
Correct |
2 ms |
324 KB |
Output is correct |
11 |
Correct |
2 ms |
340 KB |
Output is correct |
12 |
Correct |
2 ms |
324 KB |
Output is correct |
13 |
Correct |
2 ms |
328 KB |
Output is correct |
14 |
Correct |
2 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
2 ms |
396 KB |
Output is correct |
17 |
Correct |
2 ms |
340 KB |
Output is correct |
18 |
Correct |
3 ms |
340 KB |
Output is correct |
19 |
Correct |
3 ms |
340 KB |
Output is correct |
20 |
Correct |
2 ms |
340 KB |
Output is correct |
21 |
Correct |
2 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
324 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
340 KB |
Output is correct |
7 |
Correct |
2 ms |
328 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
2 ms |
324 KB |
Output is correct |
10 |
Correct |
2 ms |
324 KB |
Output is correct |
11 |
Correct |
2 ms |
340 KB |
Output is correct |
12 |
Correct |
2 ms |
324 KB |
Output is correct |
13 |
Correct |
2 ms |
328 KB |
Output is correct |
14 |
Correct |
2 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
2 ms |
396 KB |
Output is correct |
17 |
Correct |
2 ms |
340 KB |
Output is correct |
18 |
Correct |
3 ms |
340 KB |
Output is correct |
19 |
Correct |
3 ms |
340 KB |
Output is correct |
20 |
Correct |
2 ms |
340 KB |
Output is correct |
21 |
Correct |
2 ms |
340 KB |
Output is correct |
22 |
Correct |
228 ms |
1088 KB |
Output is correct |
23 |
Correct |
205 ms |
1092 KB |
Output is correct |
24 |
Correct |
186 ms |
1088 KB |
Output is correct |
25 |
Correct |
233 ms |
1140 KB |
Output is correct |
26 |
Correct |
231 ms |
1096 KB |
Output is correct |
27 |
Correct |
342 ms |
1092 KB |
Output is correct |
28 |
Correct |
312 ms |
1236 KB |
Output is correct |
29 |
Correct |
306 ms |
1248 KB |
Output is correct |
30 |
Correct |
351 ms |
1092 KB |
Output is correct |
31 |
Correct |
336 ms |
1096 KB |
Output is correct |
32 |
Correct |
413 ms |
1172 KB |
Output is correct |
33 |
Correct |
493 ms |
2240 KB |
Output is correct |
34 |
Correct |
442 ms |
1088 KB |
Output is correct |
35 |
Correct |
434 ms |
1096 KB |
Output is correct |
36 |
Correct |
439 ms |
1104 KB |
Output is correct |