Submission #970210

#TimeUsernameProblemLanguageResultExecution timeMemory
970210pccPatkice (COCI20_patkice)C++17
50 / 50
1 ms464 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...