Submission #500949

#TimeUsernameProblemLanguageResultExecution timeMemory
500949MertD014Patkice (COCI20_patkice)C++17
50 / 50
1 ms304 KiB
#include <bits/stdc++.h> using namespace std; int r,c,ro,co,rx,cx; char d[102][102]; int f(int rr,int cc,int l){ if(d[rr][cc]=='.' || d[rr][cc]=='o') return INT_MAX; if(d[rr][cc]=='x') return l; if(d[rr][cc]=='>') return f(rr,cc+1,l+1); if(d[rr][cc]=='<') return f(rr,cc-1,l+1); if(d[rr][cc]=='^') return f(rr-1,cc,l+1); if(d[rr][cc]=='v') return f(rr+1,cc,l+1); } int main(){ cin>>r>>c; for(int i=0;i<102;i++) for(int j=0;j<102;j++) d[i][j]='.'; for(int i=1;i<=r;i++){ for(int j=1;j<=c;j++){ cin>>d[i][j]; if(d[i][j]=='o'){ ro=i; co=j; } } } int ps=f(ro+1,co,1); int pn=f(ro-1,co,1); int pe=f(ro,co+1,1); int pw=f(ro,co-1,1); int mp=min(ps,min(pn,min(pe,pw))); //cout<<pn<<" "<<pe<<" "<<ps<<" "<<pw<<endl; if(mp==INT_MAX) cout<<":("; else if(mp==pe) cout<<":)\nE"; else if(mp==pn) cout<<":)\nN"; else if(mp==ps) cout<<":)\nS"; else if(mp==pw) cout<<":)\nW"; return 0; } /* 6 6 ..>>>v .o^..v .v.<.v .>>^.v .x<<<< ...... */

Compilation message (stderr)

patkice.cpp: In function 'int f(int, int, int)':
patkice.cpp:13:1: warning: control reaches end of non-void function [-Wreturn-type]
   13 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...