Submission #1036423

# Submission time Handle Problem Language Result Execution time Memory
1036423 2024-07-27T10:51:53 Z c2zi6 Wombats (IOI13_wombats) C++14
27 / 100
277 ms 10192 KB
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define replr(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define reprl(i, a, b) for (int i = int(a); i >= int(b); --i)
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define mkp(a, b) make_pair(a, b)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<VPI> VVPI;
typedef pair<ll, ll> PLL;
typedef vector<ll> VL;
typedef vector<PLL> VPL;
typedef vector<VL> VVL;
typedef vector<VVL> VVVL;
typedef vector<VPL> VVPL;
template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;}
template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;}
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T>
using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#include "wombats.h"
 
const int MAXC = 4;

struct PART;
PART combine(PART& a, PART& b);

struct PART {
    int d[MAXC][MAXC];
    PART() {
        rep(i, MAXC) rep(j, MAXC) d[i][j] = 1e9;
    }
    int* operator[](int i) {
        return d[i];
    }
    void combine(PART& b) {
        *this = ::combine(*this, b);
    }
};
PART combine(PART& a, PART& b) {
    PART c;
    /*rep(i, MAXC) rep(j, MAXC) rep(m, MAXC) setmin(c[i][j], a[i][m] + b[m][j]);*/
    /*return c;*/
    int mid[MAXC][MAXC];
    reprl(d, +MAXC, -MAXC) rep(i, MAXC) {
        int j = i-d;
        if (j < 0 || j >= MAXC) continue;
        /*int mn = 0;*/
        /*int mx = MAXC-1;*/
        /*if (j-1 >= 0) mn = mid[i][j-1];*/
        /*if (i+1 < MAXC) mx = mid[i+1][j];*/
        /*replr(m, mn, mx) {*/
        replr(m, 0, MAXC-1) {
            if (a[i][m] + b[m][j] < c[i][j]) {
                c[i][j] = a[i][m] + b[m][j];
                mid[i][j] = m;
            }
        }
    }
    return c;
}

vector<PART> a;
int n, m;
VVI H, V;
PART answer;

void recalc() {
    a = vector<PART>(n);
    rep(l, n) {
        replr(i, 0, m-1) {
            int sum = 0;
            replr(j, i, m-1) {
                a[l][i][j] = sum + V[l][j];
                a[l][j][i] = sum + V[l][i];
                sum += H[l][j];
            }
        }
    }
    answer = a[0];
    replr(i, 1, n-1) answer.combine(a[i]);
}

void init(int R, int C, int H_arg[5000][200], int V_arg[5000][200]) {
    n = R;
    m = C;
    H = V = VVI(n, VI(m));
    rep(i, n) rep(j, m-1) H[i][j] = H_arg[i][j];
    rep(i, n-1) rep(j, m) V[i][j] = V_arg[i][j];
    recalc();
}
 
void changeH(int P, int Q, int W) {
    H[P][Q] = W;
    recalc();
}
 
void changeV(int P, int Q, int W) {
    V[P][Q] = W;
    recalc();
}
 
int escape(int u, int v) {
    return answer[u][v];
}
 



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;
      |      ^~~
wombats.cpp: In function 'PART combine(PART&, PART&)':
wombats.cpp:55:9: warning: variable 'mid' set but not used [-Wunused-but-set-variable]
   55 |     int mid[MAXC][MAXC];
      |         ^~~
# Verdict Execution time Memory Grader output
1 Correct 220 ms 5468 KB Output is correct
2 Correct 227 ms 5468 KB Output is correct
3 Correct 277 ms 7052 KB Output is correct
4 Correct 223 ms 5464 KB Output is correct
5 Correct 222 ms 5464 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Runtime error 1 ms 604 KB Execution killed with signal 6
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 860 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 239 ms 9396 KB Output is correct
2 Correct 269 ms 9308 KB Output is correct
3 Correct 233 ms 9440 KB Output is correct
4 Correct 244 ms 10192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 860 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 860 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -