Submission #495667

#TimeUsernameProblemLanguageResultExecution timeMemory
495667asandikciPatkice (COCI20_patkice)C++17
0 / 50
0 ms204 KiB
#include"iostream" // #include"vector" // #include"queue" // #include"deque" // #include"set" // #include"map" // #include"algorithm" // #include"iomanip" // #include"cstring" // #define int long long using namespace std; const int maxn=105; const int INF = 1e9; pair<int,int> duck; char g[maxn][maxn]; int len=0; void dfs(int x,int y){ if(g[x][y]=='.' || g[x][y]=='o'){len=INF; return;} if(g[x][y]=='>'){ len++; dfs(x,y+1); } if(g[x][y]=='<'){ len++; dfs(x,y-1); } if(g[x][y]=='^'){ len++; dfs(x-1,y); } if(g[x][y]=='v'){ len++; dfs(x+1,y); } if(g[x][y]=='x') return; } void solve(){ int n,m; cin >> n >> m; for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ cin >> g[i][j]; if(g[i][j]=='o'){ duck = {i,j}; } } } int a,b,c,d; // cout << duck.first << "*" << duck.second << "\n"; dfs(duck.first,duck.second+1); a = len; len=0; dfs(duck.first,duck.second-1); b = len; len=0; dfs(duck.first+1,duck.second); c = len; len=0; dfs(duck.first-1,duck.second); d = len; cout << a << " " << b << " " << c << " " << d << "\n\n"; int mini = min(a,min(b,min(c,d))); if(mini==INF){cout << ":(";} else{ cout << ":)\n"; if(a==mini){cout << "E";} else if(b==mini){cout << "W";} else if(c==mini){cout << "S";} else if(d==mini){cout << "N";} } } signed main(){ // ios::sync_with_stdio(false); cin.tie(0); // freopen("","r",stdin);freopen("","w",stdout); int t=1; // cin >> t; for(int i=1;i<=t;i++){ // cout << "Case " << i << ":\n"; solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...