# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
969160 |
2024-04-24T15:49:23 Z |
HuyAT |
Nautilus (BOI19_nautilus) |
C++14 |
|
176 ms |
1044 KB |
#include<bits/stdc++.h>
const int MaxN = 5e2 + 10;
std::bitset<MaxN> f[MaxN + 1],f1[MaxN + 1],a[MaxN + 1];
int n,m,q;
void readData(){
std::cin >> n >> m >> q;
for(int i = 1;i <= n;++i){
std::string s;
std::cin >> s;
auto func = [&](char &c){
if(c == '#'){
c = '0';
}else{
c = '1';
}
};
std::for_each(s.begin(),s.end(),func);
a[i] = std::bitset<MaxN>(s + '0');
f[i] = a[i];
}
}
int solve(){
int ans = 0;
for(int i = 1;i <= q;++i){
char c;
std::cin >> c;
for(int i = 1;i <= n;++i){
if(c == 'N' || c == '?'){
f1[i] |= (a[i] & f[i + 1]);
}
}
for(int i = 1;i <= n;++i){
if(c == 'S' || c == '?'){
f1[i] |= (a[i] & f[i - 1]);
}
}
for(int i = 1;i <= n;++i){
if(c == 'W' || c == '?'){
f1[i] |= (a[i] & (f[i] << 1));
}
}
for(int i = 1;i <= n;++i){
if(c == 'E' || c == '?'){
f1[i] |= (a[i] & (f[i] >> 1));
}
}
for(int i = 1;i <= n;++i){
f[i] = f1[i];
}
for(int i = 1;i <= n;++i){
f1[i].reset();
}
}
for(int i = 1;i <= n;++i){
ans += f[i].count();
}
return ans;
}
int main(){
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);std::cout.tie(nullptr);
readData();
std::cout << solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
360 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
360 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
492 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
2 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
2 ms |
468 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
460 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
360 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
492 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
2 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
2 ms |
468 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
460 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
84 ms |
812 KB |
Output is correct |
23 |
Correct |
96 ms |
872 KB |
Output is correct |
24 |
Correct |
84 ms |
604 KB |
Output is correct |
25 |
Correct |
84 ms |
604 KB |
Output is correct |
26 |
Correct |
82 ms |
604 KB |
Output is correct |
27 |
Correct |
128 ms |
796 KB |
Output is correct |
28 |
Correct |
136 ms |
600 KB |
Output is correct |
29 |
Correct |
129 ms |
600 KB |
Output is correct |
30 |
Correct |
127 ms |
600 KB |
Output is correct |
31 |
Correct |
133 ms |
1044 KB |
Output is correct |
32 |
Correct |
169 ms |
796 KB |
Output is correct |
33 |
Correct |
173 ms |
796 KB |
Output is correct |
34 |
Correct |
176 ms |
800 KB |
Output is correct |
35 |
Correct |
172 ms |
604 KB |
Output is correct |
36 |
Correct |
167 ms |
604 KB |
Output is correct |