Submission #93947

#TimeUsernameProblemLanguageResultExecution timeMemory
93947ahmedie404Pohlepko (COCI16_pohlepko)C++14
40 / 80
1068 ms66560 KiB
#include <iostream> using namespace std; int n, m; string a[2000+9]; bool vis[2000+9][2000+9]; bool check(int i, int j){ return i >= 0 && j >= 0 && i < n && j < m; } string finds(int i, int j, string s){ char l='z'; int x,y; s += a[i][j]; if( i == n-1 && j == m-1 ) return s; if(check(i+1, j) && a[i+1][j] <= l){ l = a[i+1][j]; x=i+1, y=j; } if(check(i, j+1) && a[i][j+1] < l){ l = a[i][j+1]; x=i, y=j+1; } if(a[i+1][j] == a[i][j+1]){ int a, b; string s1; if(!vis[i+1][j]){ s1 = finds(i+1, j, s); a=i+1, b=j; } if(!vis[i][j+1]){ if(string(finds(i, j+1, s)) < string(s1)){ s1 = finds(i, j+1, s); a=i, b=j+1; } } if(check(a,b)){ vis[a][b]=true; return s1; } } vis[x][y]=true; return finds(x, y, s); } int main(){ cin >> n >> m; for(int i=0;i<n;i++) cin >> a[i]; cout << finds(0, 0, "") << endl; return 0; }

Compilation message (stderr)

pohlepko.cpp: In function 'std::__cxx11::string finds(int, int, std::__cxx11::string)':
pohlepko.cpp:33:16: warning: 'b' may be used uninitialized in this function [-Wmaybe-uninitialized]
         int a, b;
                ^
pohlepko.cpp:33:13: warning: 'a' may be used uninitialized in this function [-Wmaybe-uninitialized]
         int a, b;
             ^
pohlepko.cpp:55:25: warning: 'y' may be used uninitialized in this function [-Wmaybe-uninitialized]
     return finds(x, y, s);
                         ^
pohlepko.cpp:55:25: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
#Verdict Execution timeMemoryGrader output
Fetching results...