제출 #983899

#제출 시각아이디문제언어결과실행 시간메모리
983899NomioAwesome Arrowland Adventure (eJOI19_adventure)C++17
22 / 100
1 ms456 KiB
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int m, n;
	cin >> m >> n;
	string s[m];
	for(int i = 0; i < m; i++) {
		cin >> s[i];
	}
	map<pair<char, char>, int> M;
	M[{'N', 'E'}] = 1;
	M[{'E', 'S'}] = 1;
	M[{'S', 'W'}] = 1;
	M[{'W', 'N'}] = 1;
	M[{'N', 'S'}] = 2;
	M[{'E', 'W'}] = 2;
	M[{'S', 'N'}] = 2;
	M[{'W', 'E'}] = 2;
	M[{'N', 'W'}] = 3;
	M[{'E', 'N'}] = 3;
	M[{'S', 'E'}] = 3;
	M[{'W', 'S'}] = 3;
	if(m == 1) {
		bool w = 1;
		int S = 0;
		for(int i = 0; i < n - 1; i++) {
			if(s[0][i] == 'X') {
				w = 0;
				break;
			}
			if(s[0][i] != 'E') {
				S += M[{s[0][i], 'E'}];
			}
		}
		cout << (w ? S : -1) << '\n';
	}
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...