Submission #590783

#TimeUsernameProblemLanguageResultExecution timeMemory
590783starchanPohlepko (COCI16_pohlepko)C++17
80 / 80
84 ms8044 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define in pair<int, int> #define f first #define s second #define pb push_back #define pob pop_back #define INF (int)1e17 #define MX (int)3e5+5 #define fast() ios_base::sync_with_stdio(false); cin.tie(NULL) signed main() { fast(); int n, m; cin >> n >> m; char grid[n+1][m+1]; for(int i = 1; i <= n; i++) { for(int j = 1; j <= m; j++) cin >> grid[i][j]; } string curr = ""; curr.pb(grid[1][1]); set<in> opt; opt.insert({1,1}); int stages = n+m-2; while(stages--) { vector<pair<in, char>> v; char val = '{'; for(in ok: opt) { if(ok.f < n) { v.pb({{ok.f+1, ok.s}, grid[ok.f+1][ok.s]}); val = min(val, grid[ok.f+1][ok.s]); } if(ok.s < m) { v.pb({{ok.f, ok.s+1}, grid[ok.f][ok.s+1]}); val = min(val, grid[ok.f][ok.s+1]); } } curr.pb(val); opt.clear(); for(auto aaa: v) { if(aaa.s != val) continue; opt.insert(aaa.f); } } cout << curr; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...