Submission #249929

# Submission time Handle Problem Language Result Execution time Memory
249929 2020-07-16T13:25:58 Z MarcoMeijer Wombats (IOI13_wombats) C++14
55 / 100
20000 ms 30328 KB
#include "wombats.h"
#include <bits/stdc++.h>
using namespace std;

//macros
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> lll;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<lll> vlll;
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define RE(a,c) REP(a,0,c)
#define RE1(a,c) REP(a,1,c+1)
#define REI(a,b,c) REP(a,b,c+1)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define INF 1e9
#define pb push_back
#define fi first
#define se second
#define sz size()

const int MX = 6000;
int r, c;
int h[MX][210], v[MX][210];
int dp[MX][210];

void init(int R, int C, int H[5000][200], int V[5000][200]) {
    r=R, c=C;
    RE(i,r) RE(j,c) h[i][j]=H[i][j]; 
    RE(i,r) RE(j,c) v[i][j]=V[i][j]; 
}

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

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

int escape(int V1, int V2) {
    dp[0][V1] = 0;

    int tot=0;
    REP(j,V1+1,c) tot+=h[0][j-1], dp[0][j] = tot;

    tot=0;
    REV(j,0,V1) tot+=h[0][j], dp[0][j] = tot;

    REP(i,1,r) {
        RE(j,c) {
            dp[i][j] = dp[i-1][j]+v[i-1][j];

            tot = 0;
            REP(k,j+1,c) tot+=h[i][k-1], dp[i][j] = min(dp[i][j], dp[i-1][k]+tot+v[i-1][k]);

            tot = 0;
            REV(k,0,j) tot+=h[i][k], dp[i][j] = min(dp[i][j], dp[i-1][k]+tot+v[i-1][k]);
        }
    }

    return dp[r-1][V2];
}

Compilation message

grader.c: In function 'int main()':
grader.c:15:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
  int res;
      ^~~
# Verdict Execution time Memory Grader output
1 Correct 24 ms 16640 KB Output is correct
2 Correct 25 ms 16640 KB Output is correct
3 Correct 6006 ms 19448 KB Output is correct
4 Correct 25 ms 16640 KB Output is correct
5 Correct 24 ms 16640 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 8 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 9 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 2267 ms 2852 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 150 ms 768 KB Output is correct
2 Correct 147 ms 768 KB Output is correct
3 Correct 155 ms 888 KB Output is correct
4 Correct 160 ms 888 KB Output is correct
5 Correct 149 ms 768 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 151 ms 768 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 67 ms 20600 KB Output is correct
2 Correct 68 ms 20600 KB Output is correct
3 Correct 79 ms 20608 KB Output is correct
4 Correct 5761 ms 22056 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 152 ms 768 KB Output is correct
2 Correct 147 ms 768 KB Output is correct
3 Correct 153 ms 768 KB Output is correct
4 Correct 156 ms 768 KB Output is correct
5 Correct 155 ms 768 KB Output is correct
6 Correct 69 ms 20608 KB Output is correct
7 Correct 69 ms 20604 KB Output is correct
8 Correct 69 ms 20608 KB Output is correct
9 Correct 5795 ms 21956 KB Output is correct
10 Correct 24 ms 16640 KB Output is correct
11 Correct 23 ms 16640 KB Output is correct
12 Correct 5817 ms 19516 KB Output is correct
13 Correct 33 ms 16640 KB Output is correct
14 Correct 24 ms 16640 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 4 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 4 ms 384 KB Output is correct
25 Correct 2257 ms 2824 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 157 ms 768 KB Output is correct
28 Execution timed out 20073 ms 24056 KB Time limit exceeded
29 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 150 ms 768 KB Output is correct
2 Correct 149 ms 768 KB Output is correct
3 Correct 171 ms 888 KB Output is correct
4 Correct 152 ms 768 KB Output is correct
5 Correct 158 ms 888 KB Output is correct
6 Correct 68 ms 20608 KB Output is correct
7 Correct 68 ms 20600 KB Output is correct
8 Correct 80 ms 20600 KB Output is correct
9 Correct 5775 ms 22260 KB Output is correct
10 Correct 24 ms 16640 KB Output is correct
11 Correct 24 ms 16652 KB Output is correct
12 Correct 5853 ms 19620 KB Output is correct
13 Correct 26 ms 16640 KB Output is correct
14 Correct 23 ms 16640 KB Output is correct
15 Correct 1985 ms 30328 KB Output is correct
16 Execution timed out 20008 ms 28280 KB Time limit exceeded
17 Halted 0 ms 0 KB -