#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
using namespace std;
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e18;
string s;
int r,c,m,ans;
char a[505][505];
int chec(int x,int y){
int ii = m - 1;
while(ii>=0){
if(s[ii]=='W'){
y++;
}else if(s[ii]=='N'){
x++;
}else if(s[ii]=='E'){
y--;
}else x--;
//cout<<x<<' '<<y<<" "<<a[x][y]<<"\n";
if(a[x][y]!='.'){
//cout<<x<<' '<<y<<" "<<a[x][y]<<"\n\n";
return 0;
}
ii--;
}
return 1;
}
main(){
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>r>>c>>m;
for(int i = 1;i<=r;i++){
for(int j = 1;j<=c;j++){
cin>>a[i][j];
}
}
cin>>s;
for(int i = 1;i<=r;i++){
for(int j = 1;j<=c;j++){
if(a[i][j]=='#') continue;
if(chec(i,j)){
ans++;
//cout<<i<<" "<<j<<"\n";
}
}
}
cout<<ans;
// cout<<"\n";
// for(int i = 1;i<=r;i++){
// for(int j = 1;j<=c;j++){
// cout<<a[i][j]<<" ";
// }
// cout<<"\n";
// }
return 0;
}
/*
//order_of_key(k): Number of items strictly smaller than k .
//find_by_order(k): K-th element in a set (counting from zero).
//sum of squares n*(n+1)*(2n+1)/6
//sum of cubes [n*(n+1)/2]^2
//sum of squares for odds n*(4*n*n-1)/3
//sum of cubes for odds n*n*(2*n*n-1)
//a/b%mod = a*(b^(m-2)%mod)
//(a>>x)&1 == 0
//a^b = (a+b)-2(a&b)
//srand(time(0))-always changing
for(set<int>::iterator it=s.begin(); it!=s.end(); it++){
cout<<*it<<" ";
cout<<it->first<<" "<<it->second;
}
map
cin>>s>>ss;
s.insert(make_pair(s,ss));
sort
.
.
. .
.
bool cmp(pii a,pii b){
if (a.F == b.F){
return a.S < b.S;
}
// if (a.F > b.F) return 1;
// else return 0;
return a.F > b.F;
}
map<ll, ll> factors;
for (int i = 2; i <= sqrt(n); i++) {
while (n % i == 0) {
factors[i]++;
n /= i;
}
}
if (n != 1) {
factors[n]++;
}
for(auto now : factors){
cout<<now.F<<"^"<<now.S<<" ";
}
ll binpow(ll a, ll b){
a %= mod;
if(b == 0){
return 1;
}
if(b % 2 == 1){
return binpow (a, b - 1) % mod * a;
}
if(b % 2 == 0){
ll t = binpow (a, b / 2) % mod;
return t * t % mod;
}
}
sisteme 101010
for(char c : s)
x = x*k + (c-48);
*/
Compilation message
nautilus.cpp:34:5: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
34 | main(){
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Incorrect |
3 ms |
344 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Incorrect |
3 ms |
344 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |