Submission #575744

# Submission time Handle Problem Language Result Execution time Memory
575744 2022-06-11T08:42:03 Z jack715 Wombats (IOI13_wombats) C++14
55 / 100
20000 ms 26364 KB
#include "wombats.h"
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pp pop_back
#define mp make_pair
#define bb back
#define ff first
#define ss second

using namespace std;

vector<vector<int> > H, V, travel;
int R, C;

void build() {
    vector<int> presum(C);
    presum[0] = 0;
    for (int i = 0; i < C-1; i++) {
        presum[i+1] = H[0][i] + presum[i];
    }

    for (int i = 0; i < C; i++)
    for (int j = 0; j < C; j++) {
        if (i >= j)
            travel[i][j] = presum[i]-presum[j];
        else 
            travel[i][j] = presum[j]-presum[i];
    }

    for (int r = 1; r < R; r++) {
        presum[0] = 0;
        for (int i = 0; i < C-1; i++) {
            presum[i+1] = H[r][i] + presum[i];
        }

        for (int i = 0; i < C; i++) {
            vector<int> next(C, INT_MAX); 
            next[0] = travel[i][0] + V[r-1][0];
            int now = next[0];
            for (int j = 1; j < C; j++) {
                now = min(now+H[r][j-1], travel[i][j] + V[r-1][j]);
                next[j] = min(next[j], now);
            }
            next[C-1] = min(next[C-1], travel[i][C-1] + V[r-1][C-1]);
            now = next[C-1];
            for (int j = C-2; j >= 0; j--) {
                now = min(now+H[r][j], travel[i][j] + V[r-1][j]);
                next[j] = min(next[j], now);
            }
            travel[i] = next;
        }
    }
}

void init(int r, int c, int h[5000][200], int v[5000][200]) {
    R = r, C = c;
    H.resize(R, vector<int>(C));
    V.resize(R, vector<int>(C));
    travel.resize(C, vector<int>(C));
    
    for (int i = 0; i < R; i++)
    for (int j = 0; j < C-1; j++)
        H[i][j] = h[i][j];
    for (int i = 0; i < R-1; i++)
    for (int j = 0; j < C; j++)
        V[i][j] = v[i][j];
    
    build();
}

void changeH(int P, int Q, int W) {
    H[P][Q] = W;
    build();
}

void changeV(int P, int Q, int W) {
    V[P][Q] = W;
    build();
}

int escape(int V1, int V2) {
    return travel[V1][V2];
}

Compilation message

grader.c: In function 'int main()':
grader.c:15:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
   15 |  int res;
      |      ^~~
# Verdict Execution time Memory Grader output
1 Correct 76 ms 4692 KB Output is correct
2 Correct 72 ms 4780 KB Output is correct
3 Correct 139 ms 7500 KB Output is correct
4 Correct 74 ms 4784 KB Output is correct
5 Correct 79 ms 4820 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 64 ms 2516 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 401 ms 656 KB Output is correct
2 Correct 391 ms 696 KB Output is correct
3 Correct 392 ms 676 KB Output is correct
4 Correct 394 ms 716 KB Output is correct
5 Correct 390 ms 672 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1947 ms 656 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 154 ms 8724 KB Output is correct
2 Correct 143 ms 8708 KB Output is correct
3 Correct 144 ms 8660 KB Output is correct
4 Correct 170 ms 9924 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 392 ms 660 KB Output is correct
2 Correct 382 ms 652 KB Output is correct
3 Correct 392 ms 672 KB Output is correct
4 Correct 389 ms 660 KB Output is correct
5 Correct 385 ms 656 KB Output is correct
6 Correct 141 ms 8672 KB Output is correct
7 Correct 145 ms 8660 KB Output is correct
8 Correct 164 ms 8792 KB Output is correct
9 Correct 178 ms 10080 KB Output is correct
10 Correct 73 ms 4772 KB Output is correct
11 Correct 76 ms 4780 KB Output is correct
12 Correct 144 ms 7492 KB Output is correct
13 Correct 74 ms 4692 KB Output is correct
14 Correct 73 ms 4784 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 308 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 312 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 63 ms 2600 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1941 ms 660 KB Output is correct
28 Execution timed out 20059 ms 16436 KB Time limit exceeded
29 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 390 ms 596 KB Output is correct
2 Correct 380 ms 648 KB Output is correct
3 Correct 389 ms 660 KB Output is correct
4 Correct 392 ms 660 KB Output is correct
5 Correct 388 ms 596 KB Output is correct
6 Correct 139 ms 8736 KB Output is correct
7 Correct 138 ms 8660 KB Output is correct
8 Correct 145 ms 8856 KB Output is correct
9 Correct 167 ms 10004 KB Output is correct
10 Correct 73 ms 4768 KB Output is correct
11 Correct 72 ms 4780 KB Output is correct
12 Correct 133 ms 7592 KB Output is correct
13 Correct 73 ms 4780 KB Output is correct
14 Correct 72 ms 4692 KB Output is correct
15 Correct 3696 ms 26364 KB Output is correct
16 Execution timed out 20028 ms 24736 KB Time limit exceeded
17 Halted 0 ms 0 KB -