Submission #851375

#TimeUsernameProblemLanguageResultExecution timeMemory
851375vjudge1Patkice (COCI20_patkice)C++17
50 / 50
1 ms412 KiB
#ifndef Local #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #endif #include <bits/stdc++.h> #define int long long #define pb push_back #define lim 1000000 #define till 1000001 // # of primes till 1e6 = 7e4 using namespace std; using pii = array<int,2>; const int mod=1000000007ll; string s[1000]; int n,m; int dfs(int i,int j){ if(s[i][j]=='x'){ return 0; } if(s[i][j]=='.'||s[i][j]=='o'){ return -1; } int res=-1; switch (s[i][j]){ case '^': res=dfs(i-1,j); break; case 'v': res=dfs(i+1,j); break; case '<': res=dfs(i,j-1); break; case '>': res=dfs(i,j+1); break; } if(res==-1)return -1; else return res+1; } void solve(){ cin>>n>>m; for(int i=0;i<n;i++){ cin>>s[i]; } int si,sj; for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ if(s[i][j]=='o'){ si=i; sj=j; break; } } } int resu=-1,resd=-1,resl=-1,resr=-1; resu=dfs(si-1,sj); resd=dfs(si+1,sj); resl=dfs(si,sj-1); resr=dfs(si,sj+1); int ansi=INT_MAX; for(int i:{resu,resd,resl,resr}){ if(0<=i){ ansi=min(ansi,i); } } if(ansi==INT_MAX){ cout<<":(\n"; return; } cerr<<ansi<<"\n"; cerr<<resu<<" "<<resd<<" "<<resl<<" "<<resr<<"\n"; cout<<":)\n"; if(resr==ansi){ cout<<"E\n"; }else if(resu==ansi){ cout<<"N\n"; }else if(resd==ansi){ cout<<"S\n"; }else{ cout<<"W\n"; } } signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); #ifdef Local freopen("in","r",stdin); freopen("out","w",stdout); #endif int t=1; //cin>>t; while (t--) { solve(); } }

Compilation message (stderr)

patkice.cpp: In function 'void solve()':
patkice.cpp:63:13: warning: 'sj' may be used uninitialized in this function [-Wmaybe-uninitialized]
   63 |     resr=dfs(si,sj+1);
      |          ~~~^~~~~~~~~
patkice.cpp:63:13: warning: 'si' may be used uninitialized in this function [-Wmaybe-uninitialized]
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...