# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
865652 | vjudge1 | Pohlepko (COCI16_pohlepko) | C++11 | 33 ms | 65536 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 sts stable_sort
#define B begin()
#define rB rbegin()
#define E end()
#define rE rend()
#define F first
#define S second
#define pb push_back
#define ppb pop_back()
#define pf push_front
#define eb = emplace_back
#define ppf = pop_front()
#define L(x) ((x)<<1)
#define pii pair<int, int>
#define rB rbegin()
#define rE rend()
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ui = unsigned int;
const int MAXN = 2 * 1e3 + 1;
const int MOD = 1e9 + 7;
const int inf = INT_MAX;
const ll INF = LONG_LONG_MAX;
char v[MAXN][MAXN];
string ans[MAXN][MAXN];
int n, m;
void bfs(){
queue<pair<pair<int, int>, string> > q;
string aux = "";
aux.pb(v[1][1]);
q.push({{1, 1}, aux});
while(!q.empty()){
int x = q.front().F.F, y = q.front().F.S;
string s = q.front().S;
q.pop();
if(x > n || y > m)continue;
if(ans[x][y] == ""){
ans[x][y] = s;
}else if(ans[x][y] < s)continue;
ans[x][y] = s;
q.push({{x + 1, y}, s + v[x + 1][y]});
q.push({{x, y + 1}, s + v[x][y + 1]});
}
}
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n >> m;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
cin >> v[i][j];
}
}
bfs();
cout << ans[n][m] << '\n';
}
/**
*/
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |