# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
243437 | VEGAnn | Pohlepko (COCI16_pohlepko) | C++14 | 82 ms | 8184 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 all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define i2 array<int,2>
#define PB push_back
using namespace std;
const int N = 2010;
const int oo = 2e9;
vector<i2> vc, nw;
char c[N][N];
int n, m;
string s = "";
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL
freopen("in.txt","r",stdin);
#endif // _LOCAL
cin >> n >> m;
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
cin >> c[i][j];
vc.PB({0, 0});
while (sz(vc) > 0){
char mn = 'z';
nw.clear();
for (i2 cr : vc)
mn = min(mn, c[cr[0]][cr[1]]);
for (i2 cr : vc){
int x = cr[0], y = cr[1];
if (c[x][y] != mn) continue;
if (x < n - 1)
nw.PB({x + 1, y});
if (y < m - 1)
nw.PB({x, y + 1});
}
s += mn;
sort(all(nw));
nw.resize(unique(all(nw)) - nw.begin());
vc = nw;
}
cout << s;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |