This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
#include <unordered_map>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(x) x.begin(),x.end()
#define pb push_back
#define ent "\n"
const int maxn = (int)2e5 + 13;
const ll inf = (long long)1e18 + 20;
const int mod = (int)1e9 + 7;
int n,m,k;
char a[1001][1001];
int used[1001][1001];
bool check(int i,int j){
if(1 <= i && i <= n && 1 <= j && j <= m && a[i][j] == '.')return 1;
else return 0;
}
void solve(){
cin >> n >> m >> k;
for(int i = 1 ; i <= n ; i ++){
for(int j = 1 ; j <= m ; j ++){
cin >> a[i][j];
}
}
string s;cin >> s;
s = '+' + s;
for(int i = 1 ; i <= n ; i ++){
for(int j = 1 ; j <= m ; j ++){
if(a[i][j] == '.'){
int x = i,y = j;
int ok = 0;
for(int c = 1 ; c <= k ; c ++){
if(s[c] == 'N'){
x --;
}
else if(s[c] == 'E'){
y ++;
}
else if(s[c] == 'S'){
x ++;
}
else{
y --;
}
if(check(x,y) == 0)ok = 1;
}
if(ok)continue;
used[x][y] = 1;
}
}
}
int ans = 0;
for(int i = 1 ; i <= n ; i ++){
for(int j = 1 ; j <= n ; j ++)ans += used[i][j];
}
cout << ans;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int t = 1;
//cin >> t;
while(t --){
solve();
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |