제출 #1138321

#제출 시각아이디문제언어결과실행 시간메모리
1138321mychecksedadWombats (IOI13_wombats)C++20
39 / 100
541 ms38216 KiB
#include "wombats.h" #include<bits/stdc++.h> using namespace std; #define ll long long int #define MOD (1000000000+7) #define MOD1 (998244353) #define pb push_back #define all(x) x.begin(), x.end() #define en cout << '\n' #define ff first #define ss second #define pii pair<int,int> #define vi vector<int> const int N = 100+100, M = 1e5+10, K = 52, MX = 30; int T[5000*4][20][20], H[5000][200], V[5000][200], pref[5000][200]; int get_pref(int row, int l, int r){ if(r < l) swap(l, r); return pref[row][r] - pref[row][l]; } int n, m; void comb(int k, int mid){ for(int s = 0; s < m; ++s){ for(int e = 0; e < m; ++e){ T[k][s][e] = MOD; for(int i = 0; i < m; ++i){ T[k][s][e] = min(T[k<<1][s][i] + T[k<<1|1][i][e] + V[mid][i], T[k][s][e]); } } } } void build(int l, int r, int k){ if(l == r){ for(int j = 0; j < m; ++j){ for(int i = 0; i < m; ++i) T[k][j][i] = get_pref(l, j, i); } return; } int mid = l+r>>1; build(l, mid, k<<1); build(mid+1, r, k<<1|1); comb(k, mid); } void upd(int l, int r, int p, int k){ if(l == r){ for(int j = 0; j < m; ++j){ for(int i = 0; i < m; ++i) T[k][j][i] = get_pref(l, j, i); } return; } int mid = l+r>>1; if(p <= mid) upd(l, mid, p, k<<1); else upd(mid+1, r, p, k<<1|1); comb(k, mid); } void init(int R, int C, int HH[5000][200], int VV[5000][200]) { n = R; m = C; for(int i = 0; i < n; ++i){ for(int j = 0 ;j < m; ++j){ H[i][j] = HH[i][j]; V[i][j] = VV[i][j]; if(j == 0) pref[i][0] = 0; else pref[i][j] = pref[i][j - 1] + H[i][j - 1]; } } build(0, n - 1, 1); } void changeH(int P, int Q, int W) { H[P][Q] = W; for(int j = 0 ;j < m; ++j){ if(j == 0) pref[P][0] = 0; else pref[P][j] = pref[P][j - 1] + H[P][j - 1]; } upd(0, n - 1, P, 1); } void changeV(int P, int Q, int W) { V[P][Q] = W; upd(0, n - 1, P, 1); } int escape(int V1, int V2) { return T[1][V1][V2]; }
#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...