Submission #570377

#TimeUsernameProblemLanguageResultExecution timeMemory
570377cheissmartWombats (IOI13_wombats)C++14
76 / 100
20074 ms248960 KiB
#include "wombats.h" #include <bits/stdc++.h> #define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0); #define F first #define S second #define V vector #define PB push_back #define EB emplace_back #define MP make_pair #define SZ(v) int((v).size()) #define ALL(v) (v).begin(), (v).end() using namespace std; typedef long long ll; typedef pair<int, int> pi; typedef V<int> vi; string _reset = "\u001b[0m", _yellow = "\u001b[33m", _bold = "\u001b[1m"; void DBG() { cerr << "]" << _reset << endl; } template<class H, class...T> void DBG(H h, T ...t) { cerr << to_string(h); if(sizeof ...(t)) cerr << ", "; DBG(t...); } #ifdef CHEISSMART #define debug(...) cerr << _yellow << _bold << "Line(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__) #else #define debug(...) #endif const int INF = 1e9 + 7, mxR = 5000, mxC = 200, K = 15; int h[5000][200], v[5000][200], dp[5000][200]; int R, C; struct node { int a[mxC][mxC]; node() { memset(a, 0x3f, sizeof a); } void build(int tl, int tr) { for(int s = 0; s < C; s++) { for(int j = 0; j < C; j++) dp[tl][j] = INF; auto gogo = [&] (int row) { for(int i = 0; i + 1 < C; i++) dp[row][i + 1] = min(dp[row][i + 1], dp[row][i] + h[row][i]); for(int i = C - 2; i >= 0; i--) dp[row][i] = min(dp[row][i], dp[row][i + 1] + h[row][i]); }; dp[tl][s] = 0; gogo(tl); for(int i = tl + 1; i <= tr; i++) { for(int j = 0; j < C; j++) dp[i][j] = dp[i - 1][j] + v[i - 1][j]; gogo(i); } for(int t = 0; t < C; t++) a[s][t] = dp[tr][t]; } } void add(node& l, node& r) { for(int s = 0; s < C; s++) { for(int t = 0; t < C; t++) { int mn = INF; for(int k = 0; k < C; k++) mn = min(mn, l.a[s][k] + r.a[k][t]); a[s][t] = mn; } } } } t[350 * 4]; void upd(int pos, int v = 1, int tl = 0, int tr = R - 1) { if(tr - tl <= K) { t[v].build(tl, tr); return; } int tm = (tl + tr) / 2; if(pos < tm) upd(pos, v * 2, tl, tm); else upd(pos, v * 2 + 1, tm, tr); t[v].add(t[v * 2], t[v * 2 + 1]); } void build(int v = 1, int tl = 0, int tr = R - 1) { if(tr - tl <= K) { t[v].build(tl, tr); return; } int tm = (tl + tr) / 2; build(v * 2, tl, tm); build(v * 2 + 1, tm, tr); t[v].add(t[v * 2], t[v * 2 + 1]); } void init(int _R, int _C, int _h[5000][200], int _v[5000][200]) { memcpy(h, _h, sizeof h); memcpy(v, _v, sizeof v); R = _R, C = _C; build(); } void changeH(int P, int Q, int W) { h[P][Q] = W; if(P) upd(P - 1); upd(P); } void changeV(int P, int Q, int W) { v[P][Q] = W; upd(P); } int escape(int V1, int V2) { return t[1].a[V1][V2]; }

Compilation message (stderr)

grader.c: In function 'int main()':
grader.c:15:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
   15 |  int res;
      |      ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...