# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
967455 |
2024-04-22T06:49:07 Z |
Pring |
Wombats (IOI13_wombats) |
C++17 |
|
17 ms |
32348 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 + 1) {
dp[0][0][i] = min(dp[0][0][i - 1], dp[0][1][i - 1] + h[0][i]) + v[0][i];
dp[0][1][i] = min(dp[0][0][i - 1] + h[0][i], dp[0][1][i - 1]) + v[1][i];
dp[1][0][i] = min(dp[1][0][i - 1], dp[1][1][i - 1] + h[0][i]) + v[0][i];
dp[1][1][i] = min(dp[1][0][i - 1] + h[1][i], dp[1][1][i - 1]) + v[1][i];
}
}
}
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) {
cout << 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;
| ^~~
wombats.cpp: In function 'int escape(int, int)':
wombats.cpp:64:1: warning: no return statement in function returning non-void [-Wreturn-type]
64 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
11 ms |
21596 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
4 ms |
4700 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
7 ms |
13256 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
17 ms |
32348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
7 ms |
13148 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
8 ms |
13144 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |