// 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 = 1000 + 17;
const ll MOD = 1e9 + 7;
const string alf = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char a[N][N];
pair <int ,int > xy[] = {{1 , 0} , {-1 , 0} , {0 , 1} , {0 , -1}};
string s;
bool go (int x, int y){
if (a[x][y] == '#')return false;
for(int i= 0; i < s.size(); i ++){
if (s[i] == 'N'){
x ++;
}
else if (s[i] == 'S')x --;
else if (s[i] == 'W')y --;
else y ++;
if (a[x][y] == '#')return false;
}
return true;
}
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 >> a[i][j];
}
}
cin >> s;
for(int i = 1; i <= n; i ++){
for(int j = 1; j <= m; j ++){
if (go(i , j))ans ++;
}
}
cout << ans << endl;
}
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 'bool go(long long int, long long int)':
nautilus.cpp:32:18: 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]
32 | for(int i= 0; i < s.size(); i ++){
| ~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |