답안 #967465

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
967465 2024-04-22T07:03:00 Z Pring 웜뱃 (IOI13_wombats) C++17
0 / 100
15 ms 16172 KB
#include <bits/stdc++.h>
#ifndef MIKU
#include "wombats.h"
#endif
using namespace std;

#ifdef MIKU
string dbmc = "\033[1;38;2;57;197;187m", dbrs = "\033[0m";
#define debug(x...) cout << dbmc << "[" << #x << "]: ", dout(x)
void dout() { cout << dbrs << endl; }
template <typename T, typename ...U>
void dout(T t, U ...u) { cout << t << (sizeof...(u) ? ", " : ""); dout(u...); }
#else
#define debug(...) 39
#endif

#define fs first
#define sc second
#define mp make_pair
#define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++)
using ll = long long;
typedef pair<int, int> pii;

namespace {
    const int MXN = 5005, MXM = 200, K = 5;
    int n, m;
    int h[MXN][MXM], v[MXN][MXM];
    int dp[2][2][MXN];

    void DP() {
        dp[0][0][0] = v[0][0];
        dp[0][1][0] = h[0][0] + v[0][1];
        dp[1][0][0] = h[0][0] + v[0][0];
        dp[1][1][0] = v[0][1];
        FOR(i, 1, n) {
            dp[0][0][i] = min(dp[0][0][i - 1], dp[0][1][i - 1] + h[i][0]) + v[i][0];
            dp[0][1][i] = min(dp[0][0][i - 1] + h[i][0], dp[0][1][i - 1]) + v[i][1];
            dp[1][0][i] = min(dp[1][0][i - 1], dp[1][1][i - 1] + h[i][0]) + v[i][0];
            dp[1][1][i] = min(dp[1][0][i - 1] + h[i][0], dp[1][1][i - 1]) + v[i][1];
        }
    }
}

void init(int R, int C, int H[][200], int V[][200]) {
    n = R;
    m = C;
    FOR(i, 0, n) copy(H[i], H[i] + m - 1, h[i]);
    FOR(i, 0, n - 1) copy(V[i], V[i] + m, v[i]);
    DP();
}

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

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

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

#ifdef MIKU
int hh[MXN][MXM], vv[MXN][MXM];
void miku() {
    int nn, mm;
    cin >> nn >> mm;
    FOR(i, 0, nn) FOR(j, 0, mm - 1) cin >> hh[i][j];
    FOR(i, 0, nn - 1) FOR(j, 0, mm) cin >> vv[i][j];
    init(nn, mm, hh, vv);
    int ee;
    cin >> ee;
    while (ee--) {
        int t;
        cin >> t;
        if (t == 1) {
            int p, q, w;
            cin >> p >> q >> w;
            changeH(p, q, w);
        } else if (t == 2) {
            int p, q, w;
            cin >> p >> q >> w;
            changeV(p, q, w);
        } else {
            int v1, v2;
            cin >> v1 >> v2;
            cout << escape(v1, v2) << '\n';
        }
    }
}

int32_t main() {
    cin.tie(0) -> sync_with_stdio(false);
    cin.exceptions(cin.failbit);
    miku();
    return 0;
}
#endif

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 13 ms 10844 KB Output is correct
2 Incorrect 15 ms 10844 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Incorrect 1 ms 2396 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 6488 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 16172 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 6492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 6488 KB Output isn't correct
2 Halted 0 ms 0 KB -