Submission #929586

#TimeUsernameProblemLanguageResultExecution timeMemory
929586vjudge1Nautilus (BOI19_nautilus)C++17
100 / 100
147 ms1008 KiB
#include <bits/stdc++.h>
using namespace std;

#define N 505

int r, c, m;
string s;

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
        
 	cin >> r >> c >> m;

 	// bitset<5> tes;
 	// tes.set(3);
 	// cout << tes << " W :" << (tes >> 1) << " E:" << (tes << 1) << "\n";

 	vector<bitset<N>> base(N), thispos(N); 

 	for (int i = 1; i <= r; i++){
 		for (int j = 1; j <= c; j++){
 			char typ;
 			cin >> typ;
 			if (typ == '#') continue;
 			base[i].set(j);
 		}
 	}

 	thispos = base;

 	cin >> s;
 	s = " " + s;

 	for (int i = 1; i <= m; i++){
 		vector<bitset<N>> tmp(N);
 		if (s[i] == '?' || s[i] == 'N'){
 			for (int j = 1; j < r; j++){
 				tmp[j] = thispos[j + 1];
 			}
 		}
 		if (s[i] == '?' || s[i] == 'E'){
 			for (int j = 1; j <= r; j++){
 				tmp[j] |= (thispos[j] << 1);
 			}
 		}	
 		if (s[i] == '?' || s[i] == 'S'){
 			for (int j = 2; j <= r; j++){
 				tmp[j] |= thispos[j - 1];
 			}
 		}
 		if (s[i] == '?' || s[i] == 'W'){
 			for (int j = 1; j <= r; j++){
 				tmp[j] |= (thispos[j] >> 1);
 			}
 		}
 		for (int j = 1; j <= r; j++) thispos[j] = (tmp[j] & base[j]);
 	}

 	int res = 0;
 	for (int i = 1; i <= r; i++) res += thispos[i].count();
 	cout << res;

    return 0;
}     
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...