Submission #1211702

#TimeUsernameProblemLanguageResultExecution timeMemory
1211702mehraliiAwesome Arrowland Adventure (eJOI19_adventure)C++20
0 / 100
0 ms328 KiB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

static mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define ll long long
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define F fist
#define S second

constexpr int MAXN = 1e5;
const int LOG = __lg(MAXN)+1;

constexpr int INF = 1e9;
constexpr int MOD = 1e9+7;
constexpr double EPS = 1e-8;

/*
	EJOI 2019, Day 2, problem A, 22p.
*/

int f(char c){
	if (c == 'S'){
		return 0;
	} else if (c == 'E'){
		return 1;
	} else if(c == 'N'){
		return 2;
	} else{
		return 3;
	}
}

void solve(){
	int n, m;
	cin >> n >> m;
	
	vector<string> grid(n);
	for(auto& x: grid){
		cin >> x;
	}

	int res = 0;
	for(int i = 0; i + 1 < n; i++){
		if (grid[i][0] == 'X'){
			cout << "-1\n";
			return;
		}
		res += f(grid[i][0]);
	}
	
	cout << res << '\n';
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int t = 1;
	// cin >> t;
	for(int i = 1; i <= t; i++){
		solve();
	}
}
#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...