#include<bits/stdc++.h>
#define ios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ff first
#define ss second
using namespace std;
const int N=2*1e5+7;
string a[N];
bool u[N][N];
int n, m, q;
ll ans=0;
string s;
void rec(ll x, ll y, ll pos){
if (x >= n || x < 0 || y >= m || y < 0 || a[x][y] == '#') return ;
// cout << x <<" " << y <<" " << pos <<" " << q <<"\n";
if (pos > q) {
u[x][y]=1; return ;
}
if (s[pos] == 'N') rec(x-1, y, pos+1);
if (s[pos] == 'E') rec(x, y+1, pos+1);
if (s[pos] == 'W') rec(x, y-1, pos+1);
if (s[pos] == 'S') rec(x+1, y, pos+1);
return ;
}
int main()
{
cin >> n >> m >> q;
for (int i=0;i<n;i++) cin >> a[i];
cin >> s;
s=" "+s;
for (int i=0;i<n;i++){
for (int j=0;j<m;j++){
if (a[i][j] != '#'){
if (i == 0 and j == 1) rec(i, j, 0);
}
}
}
for (int i=0;i<n;i++) {
for (int j=0;j<m;j++) if (u[i][j]) ans++;
}
cout << ans;
}
Compilation message
/tmp/cccgyIgl.o: in function `__tcf_0':
nautilus.cpp:(.text+0x9): relocation truncated to fit: R_X86_64_PC32 against symbol `a[abi:cxx11]' defined in .bss section in /tmp/cccgyIgl.o
/tmp/cccgyIgl.o: in function `rec(long long, long long, long long)':
nautilus.cpp:(.text+0x6c): relocation truncated to fit: R_X86_64_PC32 against symbol `a[abi:cxx11]' defined in .bss section in /tmp/cccgyIgl.o
/tmp/cccgyIgl.o: in function `main':
nautilus.cpp:(.text.startup+0x10): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cin' defined in .bss._ZSt3cin section in /usr/lib/gcc/x86_64-linux-gnu/10/libstdc++.a(globals_io.o)
nautilus.cpp:(.text.startup+0x18): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cin' defined in .bss._ZSt3cin section in /usr/lib/gcc/x86_64-linux-gnu/10/libstdc++.a(globals_io.o)
nautilus.cpp:(.text.startup+0x1f): relocation truncated to fit: R_X86_64_PC32 against symbol `a[abi:cxx11]' defined in .bss section in /tmp/cccgyIgl.o
nautilus.cpp:(.text.startup+0x94): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cin' defined in .bss._ZSt3cin section in /usr/lib/gcc/x86_64-linux-gnu/10/libstdc++.a(globals_io.o)
nautilus.cpp:(.text.startup+0x190): relocation truncated to fit: R_X86_64_PC32 against symbol `a[abi:cxx11]' defined in .bss section in /tmp/cccgyIgl.o
nautilus.cpp:(.text.startup+0x277): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cout' defined in .bss._ZSt4cout section in /usr/lib/gcc/x86_64-linux-gnu/10/libstdc++.a(globals_io.o)
/tmp/cccgyIgl.o: in function `_GLOBAL__sub_I__Z1aB5cxx11':
nautilus.cpp:(.text.startup+0x32b): relocation truncated to fit: R_X86_64_PC32 against `.bss'
nautilus.cpp:(.text.startup+0x345): relocation truncated to fit: R_X86_64_PC32 against `.bss'
nautilus.cpp:(.text.startup+0x351): additional relocation overflows omitted from the output
/usr/bin/ld: failed to convert GOTPCREL relocation; relink with --no-relax
collect2: error: ld returned 1 exit status