# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
167160 | egekabas | Pohlepko (COCI16_pohlepko) | C++14 | 1064 ms | 65540 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<int, int> pii;
typedef pair<ld, ld> pld;
int n, m;
char a[2009][2009];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
//freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
cin >> n >> m;
for(int i = 1; i <= n; ++i)
for(int j = 1; j <= m; ++j)
cin >> a[i][j];
vector<pii> cur = {{1, 1}};
string s;
s.pb(a[1][1]);
while(1){
vector<pii> nxt[30];
for(auto u : cur){
if(u == mp(n, m))
goto END;
if(u.ff+1 <= n)
nxt[a[u.ff+1][u.ss]-'a'].pb({u.ff+1, u.ss});
if(u.ss+1 <= m)
nxt[a[u.ff][u.ss+1]-'a'].pb({u.ff, u.ss+1});
}
for(int i = 0; i < 'z'-'a'; ++i){
if(nxt[i].size() > 0){
cur = nxt[i];
s.pb((char)(i+'a'));
break;
}
}
}
END:;
cout << s << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |