답안 #321297

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
321297 2020-11-12T01:02:56 Z thecodingwizard 웜뱃 (IOI13_wombats) C++11
0 / 100
13 ms 21356 KB
#include <bits/stdc++.h>
#include "wombats.h"

using namespace std;

using ll = long long;
#define ii pair<int, int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define F0R(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define inf 1000000010

int n, c;
int BLOCK = 30;
int H[5000][200], V[5000][200];
int psH[5000][200];

int st[(1 << 11)][200][200];

// Merges A with B, storing the result in C
void merge(int A[200][200], int B[200][200], int C[200][200]) {
    int p[200][200];
    F0R(i, c) F0R(j, c) C[i][j] = inf;
    for (int len = -c; len <= c; len++) {
        F0R(i, c) {
            int j = i + len;
            if (j >= 0 && j < c) {
                int lowerBound = j-1>=0?p[i][j-1]:0, upperBound = i+1<c?p[i+1][j]:c-1;
                for (int tgt = lowerBound; tgt <= upperBound; tgt++) {
                    if (C[i][j] >= A[i][tgt] + B[tgt][j]) {
                        C[i][j] = A[i][tgt] + B[tgt][j];
                        p[i][j] = tgt;
                    }
                }
            }
        }
    }
}

void build(int p, int i, int j) {
    if (j - i + 1 <= BLOCK) {
        FOR(rowIdx, i, 1) {
            int x[200][200], y[200][200], z[200][200];
            F0R(idx, c) {
                F0R(idx2, c) {
                    x[idx][idx2] = abs(psH[rowIdx][idx2]-psH[rowIdx][idx])+V[rowIdx][idx2];
                    y[idx][idx2] = abs(psH[rowIdx+1][idx2]-psH[rowIdx+1][idx]);
                }
            }
            merge(x, y, z);
            int tmp[200][200];
            if (rowIdx == i) {
                F0R(a, c) F0R(b, c) tmp[a][b]= z[a][b];
            } else {
                merge(st[p], z, tmp);
            }
            F0R(a, c) F0R(b, c) st[p][a][b] = tmp[a][b];
        }
        return;
    }
    build(p*2, i, (i+j)/2);
    build(p*2+1, (i+j)/2+1, j);
    merge(st[p*2], st[p*2+1], st[p]);
}

void init(int R, int C, int _H[5000][200], int _V[5000][200]) {
    n = R; c = C; F0R(i, R) F0R(j, C) { H[i][j] = _H[i][j]; V[i][j] = _V[i][j]; }
    F0R(i, n) F0R(j, c) psH[i][j] = j == 0 ? 0 : psH[i][j-1] + H[i][j-1];
    build(1, 0, n-1);

    //F0R(i, c) F0R(j, c) { cerr << "(" << i << ", " << j << "): " << st[1][i][j] << endl; }
}

void changeH(int P, int Q, int W) {
    /* ... */
}

void changeV(int P, int Q, int W) {
    /* ... */
}

int escape(int V1, int V2) {
    return st[1][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;
      |      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 17260 KB Output is correct
2 Incorrect 10 ms 17260 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 1 ms 620 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1516 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 13 ms 21356 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1516 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1644 KB Output isn't correct
2 Halted 0 ms 0 KB -