Submission #1016116

#TimeUsernameProblemLanguageResultExecution timeMemory
1016116vjudge1Patkice (COCI20_patkice)C++17
50 / 50
1 ms440 KiB
#include <bits/stdc++.h> using namespace std; const int M = 101; char a[M][M]; pair<char,int> calc(int x,int y) { pair<char,int> ans; if (a[x][y]=='^') ans=calc(x-1,y); else if (a[x][y]=='>') ans=calc(x,y+1); else if (a[x][y]=='<') ans=calc(x,y-1); else if(a[x][y]=='v') ans=calc(x+1,y); else return {a[x][y],0}; ans.second++; return ans; } int main() { int n,m; cin>>n>>m; int sti,stj; for (int i=0;i<n;i++) for (int j=0;j<m;j++) { cin>>a[i][j]; if (a[i][j]=='o') sti=i,stj=j; } int px[4]={0,-1,1,0},py[4]={1,0,0,-1}; string dir="ENSW"; int mn=M*M; char ans; for (int d=0;d<4;d++) { int ci=sti+px[d],cj=stj+py[d]; auto x=calc(ci,cj); if (x.first=='x') { if (mn>x.second) mn=x.second,ans=dir[d]; } } if (mn<M*M) { cout<<":)"<<endl; cout<<ans<<endl; } else cout<<":("<<endl; return 0; }

Compilation message (stderr)

patkice.cpp: In function 'int main()':
patkice.cpp:44:20: warning: 'stj' may be used uninitialized in this function [-Wmaybe-uninitialized]
   44 |   int ci=sti+px[d],cj=stj+py[d];
      |                    ^~
patkice.cpp:44:7: warning: 'sti' may be used uninitialized in this function [-Wmaybe-uninitialized]
   44 |   int ci=sti+px[d],cj=stj+py[d];
      |       ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...