Submission #105946

#TimeUsernameProblemLanguageResultExecution timeMemory
105946leonardaPohlepko (COCI16_pohlepko)C++14
45 / 80
1078 ms25612 KiB
#include<bits/stdc++.h> using namespace std; #define pb push_back const int maxn = 2000 + 5; int n, m; char a[maxn][maxn]; string fuki(string t1, string t2) { for(int i = 0; i < t1.size(); ++i) { if(t1[i] < t2[i]) return t1; if(t2[i] < t1[i]) return t2; } return t1; } string solve(int x, int y, string dosad) { if(x == n - 1 and y == m - 1) return dosad; else if(x == n - 1 and y != m - 1) return solve(x, y + 1, dosad + a[x][y + 1]); else if(x != n - 1 and y == m - 1) return solve(x + 1, y, dosad + a[x + 1][y]); else if(x != n - 1 and y != m - 1 and a[x + 1][y] < a[x][y + 1]) return solve(x + 1, y, dosad + a[x + 1][y]); else if(x != n - 1 and y != m - 1 and a[x][y + 1] < a[x + 1][y]) return solve(x, y + 1, dosad + a[x][y + 1]); else return fuki(solve(x, y + 1, dosad + a[x][y + 1]), solve(x + 1, y, dosad + a[x + 1][y])); } int main () { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; for(int i = 0; i < n; ++i) for(int j = 0; j < m; ++j) cin >> a[i][j]; string geez; geez.pb(a[0][0]); cout << solve(0, 0, geez); return 0; }

Compilation message (stderr)

pohlepko.cpp: In function 'std::__cxx11::string fuki(std::__cxx11::string, std::__cxx11::string)':
pohlepko.cpp:9:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < t1.size(); ++i) {
                 ~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...