#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define debug(x) cerr << #x << " " << x << "\n"
#define debug_with_space(x) cerr << #x << " " << x << " "
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair <ll, ll> pii;
typedef pair <ll, pii> piii;
typedef tree <pii, null_type, less <pii>, rb_tree_tag, tree_order_statistics_node_update> OST;
const ll NMAX = 100001;
const ll INF = (1LL << 60);
const ll MOD = 1000000007;
const ll BLOCK = 101;
const ll nr_of_bits = 35;
bitset <505 * 505> init, b, nou, cop;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n, m, t;
cin >> n >> m >> t;
int cc = 0;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
char c;
cin >> c;
if(c != '#'){
cc++;
init[i * (m + 2) + j + 1].flip();
}
}
}
string s;
cin >> s;
b = init;
m+=2;
n+=2;
for(int i = 0; i < s.size(); i++){
if(s[i] != '?'){
if(s[i] == 'E'){
b <<= 1;
}else if(s[i] == 'W'){
b >>= 1;
}else if(s[i] == 'N'){
b >>= m;
}else{
b <<= m;
}
b &= init;
}else{
cop = b;
nou = b;
nou <<= 1;
nou &= init;
b = nou;
nou = cop;
nou >>= 1;
nou &= init;
b |= nou;
nou = cop;
nou >>= m;
nou &= init;
b |= nou;
nou = cop;
nou <<= m;
nou &= init;
b |= nou;
b &= init;
}
}
cout << b.count();
return 0;
}
Compilation message
nautilus.cpp: In function 'int main()':
nautilus.cpp:44:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
44 | for(int i = 0; i < s.size(); i++){
| ~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
3 ms |
492 KB |
Output is correct |
8 |
Correct |
3 ms |
492 KB |
Output is correct |
9 |
Correct |
3 ms |
504 KB |
Output is correct |
10 |
Correct |
3 ms |
620 KB |
Output is correct |
11 |
Correct |
3 ms |
492 KB |
Output is correct |
12 |
Correct |
4 ms |
492 KB |
Output is correct |
13 |
Correct |
4 ms |
492 KB |
Output is correct |
14 |
Correct |
4 ms |
492 KB |
Output is correct |
15 |
Correct |
4 ms |
620 KB |
Output is correct |
16 |
Correct |
4 ms |
492 KB |
Output is correct |
17 |
Correct |
5 ms |
492 KB |
Output is correct |
18 |
Correct |
5 ms |
492 KB |
Output is correct |
19 |
Correct |
5 ms |
492 KB |
Output is correct |
20 |
Correct |
5 ms |
492 KB |
Output is correct |
21 |
Correct |
5 ms |
492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
3 ms |
492 KB |
Output is correct |
8 |
Correct |
3 ms |
492 KB |
Output is correct |
9 |
Correct |
3 ms |
504 KB |
Output is correct |
10 |
Correct |
3 ms |
620 KB |
Output is correct |
11 |
Correct |
3 ms |
492 KB |
Output is correct |
12 |
Correct |
4 ms |
492 KB |
Output is correct |
13 |
Correct |
4 ms |
492 KB |
Output is correct |
14 |
Correct |
4 ms |
492 KB |
Output is correct |
15 |
Correct |
4 ms |
620 KB |
Output is correct |
16 |
Correct |
4 ms |
492 KB |
Output is correct |
17 |
Correct |
5 ms |
492 KB |
Output is correct |
18 |
Correct |
5 ms |
492 KB |
Output is correct |
19 |
Correct |
5 ms |
492 KB |
Output is correct |
20 |
Correct |
5 ms |
492 KB |
Output is correct |
21 |
Correct |
5 ms |
492 KB |
Output is correct |
22 |
Correct |
96 ms |
528 KB |
Output is correct |
23 |
Correct |
99 ms |
780 KB |
Output is correct |
24 |
Correct |
97 ms |
748 KB |
Output is correct |
25 |
Correct |
106 ms |
780 KB |
Output is correct |
26 |
Correct |
92 ms |
748 KB |
Output is correct |
27 |
Correct |
171 ms |
748 KB |
Output is correct |
28 |
Correct |
177 ms |
876 KB |
Output is correct |
29 |
Correct |
177 ms |
876 KB |
Output is correct |
30 |
Correct |
177 ms |
748 KB |
Output is correct |
31 |
Correct |
177 ms |
748 KB |
Output is correct |
32 |
Correct |
234 ms |
748 KB |
Output is correct |
33 |
Correct |
235 ms |
876 KB |
Output is correct |
34 |
Correct |
238 ms |
876 KB |
Output is correct |
35 |
Correct |
233 ms |
748 KB |
Output is correct |
36 |
Correct |
236 ms |
748 KB |
Output is correct |