Submission #167177

# Submission time Handle Problem Language Result Execution time Memory
167177 2019-12-06T08:07:49 Z egekabas Pohlepko (COCI16_pohlepko) C++14
70 / 80
313 ms 65540 KB
#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<ll, ll>  pii;
typedef pair<ld, ld>  pld;
int n, m;
char a[2009][2009];
int mark[2009][2009];
string s;
vector<pii> v[4009];
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];
    for(int i = 1; i <= n; ++i)
        for(int j = 1; j <= m; ++j)
            v[i-1+j-1].pb({i, j});
    mark[1][1] = 1;
    s.pb(a[1][1]);
    for(int i = 1; i <= n+m-2; ++i){
        int mini = 1e9;
        for(auto u : v[i]){
            if(mark[u.ff-1][u.ss] == 1 || mark[u.ff][u.ss-1] == 1)
                mini = min(mini, (int)a[u.ff][u.ss]);
        }
        s.pb(mini);
        for(auto u : v[i]){
            if(mark[u.ff-1][u.ss] == 1 || mark[u.ff][u.ss-1] == 1){
                if(a[u.ff][u.ss] == mini)
                    mark[u.ff][u.ss] = 1;
            }
        }
    }
    cout << s << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 4 ms 3420 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 3 ms 760 KB Output is correct
5 Correct 3 ms 760 KB Output is correct
6 Correct 20 ms 8440 KB Output is correct
7 Correct 120 ms 35704 KB Output is correct
8 Runtime error 313 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Correct 3 ms 1144 KB Output is correct
10 Correct 8 ms 3064 KB Output is correct
11 Correct 10 ms 3448 KB Output is correct
12 Correct 34 ms 14712 KB Output is correct
13 Correct 26 ms 16632 KB Output is correct
14 Runtime error 289 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
15 Correct 4 ms 1528 KB Output is correct
16 Correct 162 ms 47068 KB Output is correct