Submission #851344

#TimeUsernameProblemLanguageResultExecution timeMemory
851344vjudge1Patkice (COCI20_patkice)C++17
0 / 50
1 ms348 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[100]; int n,m; int dfs(int i,int j){ if(s[i][j]=='x'){ return 0; } if(s[i][j]=='.'){ return -1; } int res; 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; } } } int resu=-1,resd=-1,resl=-1,resr=-1; if(si){ resu=dfs(si-1,sj); } if(si<n-1){ resd=dfs(si+1,sj); } if(sj){ resl=dfs(si,sj-1); } if(sj<m-1){ resr=dfs(si,sj+1); } int ansi=INT_MAX; for(int i:{resd,resl,resr}){ if(0<=i&&i<ansi){ ansi=i; } } if(ansi==INT_MAX){ cout<<":(\n"; return; } 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 #ifndef INTERACTIVE freopen("in","r",stdin); freopen("out","w",stdout); #endif #endif int t=1; //cin>>t; while (t--) { solve(); } }

Compilation message (stderr)

patkice.cpp: In function 'long long int dfs(long long int, long long int)':
patkice.cpp:41:21: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
   41 |     else return res+1;
      |                     ^
patkice.cpp: In function 'void solve()':
patkice.cpp:59:5: warning: 'si' may be used uninitialized in this function [-Wmaybe-uninitialized]
   59 |     if(si){
      |     ^~
patkice.cpp:69:17: warning: 'sj' may be used uninitialized in this function [-Wmaybe-uninitialized]
   69 |         resr=dfs(si,sj+1);
      |              ~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...