Submission #970210

# Submission time Handle Problem Language Result Execution time Memory
970210 2024-04-26T07:58:52 Z pcc Patkice (COCI20_patkice) C++17
50 / 50
1 ms 464 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
#define tlll tuple<ll,ll,ll>


const int mxn = 110;
string arr[mxn];
int N,M;
vector<pair<int,char>> ans;
pii dir[] = {{0,1},{0,-1},{1,0},{-1,0}};
string dd = "EWSN";
bitset<mxn> vis[mxn];
pii s,e;

int mv(int r,int c){
	for(auto &i:vis)i.reset();
	int re = 1;
	while(r != e.fs||c != e.sc){
		if(vis[r][c])return -1;
		vis[r][c] = true;
		re++;
		if(arr[r][c] == '>')c++;
		else if(arr[r][c] == '<')c--;
		else if(arr[r][c] == '^')r--;
		else if(arr[r][c] == 'v')r++;
		else return -1;
	}
	return re;
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>N>>M;
	for(int i = 0;i<N;i++){
		cin>>arr[i];
		for(int j = 0;j<M;j++){
			if(arr[i][j] == 'o')s = pii(i,j);
			else if(arr[i][j] == 'x')e = pii(i,j);
		}
	}
	for(int i = 0;i<4;i++){
		int len = mv(dir[i].fs+s.fs,dir[i].sc+s.sc);
		if(len != -1)ans.push_back(make_pair(len,dd[i]));
	}
	sort(ans.begin(),ans.end());
	if(ans.empty()){
		cout<<":(\n";
		return 0;
	}
	else{
		cout<<":)\n"<<ans[0].sc<<'\n';
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 464 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 464 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 460 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 344 KB Output is correct