// Problem: A - Nautilus
// Contest: Virtual Judge - Yosik IOI contest #1
// URL: https://vjudge.net/contest/601761#problem/A
// Memory Limit: 256 MB
// Time Limit: 1000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
#define all(v) (v).begin(),(v).end()
#define rall(v) ((v).rbegin()), ((v).rend())
#define out(v) for(auto& i : v) cout << i << ' ';
#define F first
#define S second
#define int long long
const ll N = 5000 + 17;
const ll MOD = 1e9 + 7;
const string alf = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char c[N][N];
bitset <505> a[N] , cop[N] , f, no[N] , es[N] , we[N] , so[N];
void solve (){
int n , m , k;
cin >> n >> m >> k;
int ans = 0;
for(int i = 1; i <= n; i ++){
for(int j = 1;j <= m; j ++){
cin >> c[i][j];
if (c[i][j] == '.'){
a[i][j] = 1;
cop[i][j] = 1;
}
}
}
string s;
cin >> s;
for(int i = 0 ; i< s.size(); i ++){
if (s[i] == 'W'){
for(int i = 1; i <= n; i ++){
a[i] >>= 1;
}
}
else if (s[i] == 'E'){
for(int i = 1; i <= n; i ++){
a[i] <<= 1;
}
}
else if (s[i] == 'S'){
for(int i = n; i >= 2; i --){
a[i] = a[i - 1];
}
a[1] = f;
}
else if (s[i] == 'N'){
for(int i = 1; i <= n - 1; i ++){
a[i] = a[i + 1];
}
a[n] = f;
}
else {
for(int i = 1; i <= n; i ++){
we[i] = (a[i] >> 1);
}
for(int i = 1; i <= n; i ++){
es[i] = (a[i] << 1);
}
for (int i = 1; i <= n; i ++) {
if (i != 1)no[i] = a[i - 1];
if (i != n)so[i] = a[i + 1];
}
for(int i =1; i <= n; i ++){
a[i] = (((we[i] | es[i]) | no[i]) | so[i]);
}
}
for(int i = 1; i <= n; i ++){
a[i] &= cop[i];
}
}
for(int i = 1; i <= n; i ++){
for(int j = 1; j <= m; j ++){
if (a[i][j]){
ans ++;
}
}
}
cout << ans;
}
signed main(){
// freopen("ones.in" , "r" , stdin) ;
// freopen("ones.out" , "w" , stdout) ;
ios::sync_with_stdio(false);
cin.tie(0);
int T = 1;
// int cs = 1;
// cin >>T;
while (T --){
// cout <<"Case " << cs ++<< ":" << endl;
solve ();
// cout <<endl;
}
}
Compilation message
nautilus.cpp: In function 'void solve()':
nautilus.cpp:44:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
44 | for(int i = 0 ; i< s.size(); i ++){
| ~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4572 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4572 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4444 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
4444 KB |
Output is correct |
12 |
Correct |
1 ms |
4572 KB |
Output is correct |
13 |
Correct |
1 ms |
4444 KB |
Output is correct |
14 |
Correct |
1 ms |
4444 KB |
Output is correct |
15 |
Correct |
1 ms |
4440 KB |
Output is correct |
16 |
Correct |
1 ms |
4444 KB |
Output is correct |
17 |
Correct |
1 ms |
4576 KB |
Output is correct |
18 |
Correct |
1 ms |
4572 KB |
Output is correct |
19 |
Correct |
1 ms |
4444 KB |
Output is correct |
20 |
Correct |
1 ms |
4444 KB |
Output is correct |
21 |
Correct |
1 ms |
4444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4572 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4444 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
4444 KB |
Output is correct |
12 |
Correct |
1 ms |
4572 KB |
Output is correct |
13 |
Correct |
1 ms |
4444 KB |
Output is correct |
14 |
Correct |
1 ms |
4444 KB |
Output is correct |
15 |
Correct |
1 ms |
4440 KB |
Output is correct |
16 |
Correct |
1 ms |
4444 KB |
Output is correct |
17 |
Correct |
1 ms |
4576 KB |
Output is correct |
18 |
Correct |
1 ms |
4572 KB |
Output is correct |
19 |
Correct |
1 ms |
4444 KB |
Output is correct |
20 |
Correct |
1 ms |
4444 KB |
Output is correct |
21 |
Correct |
1 ms |
4444 KB |
Output is correct |
22 |
Correct |
59 ms |
6748 KB |
Output is correct |
23 |
Correct |
60 ms |
6748 KB |
Output is correct |
24 |
Correct |
63 ms |
6896 KB |
Output is correct |
25 |
Correct |
58 ms |
6880 KB |
Output is correct |
26 |
Correct |
56 ms |
6896 KB |
Output is correct |
27 |
Correct |
101 ms |
6892 KB |
Output is correct |
28 |
Correct |
102 ms |
6748 KB |
Output is correct |
29 |
Correct |
103 ms |
6744 KB |
Output is correct |
30 |
Correct |
102 ms |
6892 KB |
Output is correct |
31 |
Correct |
102 ms |
6748 KB |
Output is correct |
32 |
Correct |
139 ms |
6748 KB |
Output is correct |
33 |
Correct |
141 ms |
6896 KB |
Output is correct |
34 |
Correct |
136 ms |
6748 KB |
Output is correct |
35 |
Correct |
135 ms |
6900 KB |
Output is correct |
36 |
Correct |
134 ms |
6748 KB |
Output is correct |