답안 #225529

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
225529 2020-04-20T19:39:34 Z cgiosy 웜뱃 (IOI13_wombats) C++17
100 / 100
8194 ms 222696 KB
#pragma GCC optimize("O3")
#pragma GCC target("arch=haswell")
#include "wombats.h"
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define reset(a) memset(a, 0x3f, sizeof a)
using namespace std;
constexpr int K=8, SZ=1512;

int N, M, X[5000][200], Y[5000][200];
int T[SZ][200][200], L[SZ], R[SZ], id=1;
int& mini(int& x, int y) { return x=min(x, y); }
void build(int l, int r, int s=0, int e=N-1, int t=0) {
	auto &D=T[t];
	reset(D);
	if(s==e) {
		rep(i, M) D[i][i]=0;
		rep(y, K) {
			int i=s*K+y;
			rep(j, M) {
				rep(k, M-1) mini(D[j][k+1], D[j][k]+X[i][k]);
				rep(k, M-1) mini(D[j][M-k-2], D[j][M-k-1]+X[i][M-k-2]);
				rep(k, M) D[j][k]+=Y[i][k];
			}
		}
		return;
	}

	int m=s+e>>1;
	if(l<=m) build(l, r, s, m, L[t]=L[t] ?: id++);
	if(r>m) build(l, r, m+1, e, R[t]=R[t] ?: id++);

	auto &A=T[L[t]], &B=T[R[t]];
	rep(a, M) rep(i, M) rep(b, M)
		D[a][b]=min(D[a][b], A[a][i]+B[i][b]);
}
void init(int P, int Q, int H[5000][200], int V[5000][200]) {
	N=(P+K-1)/K, M=Q;
	reset(X);
	rep(i, P) rep(j, Q-1) X[i][j]=H[i][j];
	rep(i, P-1) rep(j, Q) Y[i][j]=V[i][j];
	build(0, N-1);
}
void changeH(int p, int q, int w) { X[p][q]=w; build(p/K, p/K); }
void changeV(int p, int q, int w) { Y[p][q]=w; build(p/K, p/K); }
int escape(int a, int b) { return T[0][a][b]; }

Compilation message

grader.c: In function 'int main()':
grader.c:15:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
  int res;
      ^~~
wombats.cpp: In function 'void build(int, int, int, int, int)':
wombats.cpp:29:9: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  int m=s+e>>1;
        ~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 138 ms 207608 KB Output is correct
2 Correct 136 ms 207608 KB Output is correct
3 Correct 219 ms 210424 KB Output is correct
4 Correct 155 ms 207608 KB Output is correct
5 Correct 137 ms 207608 KB Output is correct
6 Correct 7 ms 4352 KB Output is correct
7 Correct 7 ms 4352 KB Output is correct
8 Correct 6 ms 4480 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 4352 KB Output is correct
2 Correct 6 ms 4352 KB Output is correct
3 Correct 6 ms 4352 KB Output is correct
4 Correct 7 ms 5120 KB Output is correct
5 Correct 7 ms 5120 KB Output is correct
6 Correct 7 ms 5120 KB Output is correct
7 Correct 8 ms 5120 KB Output is correct
8 Correct 7 ms 5120 KB Output is correct
9 Correct 7 ms 5120 KB Output is correct
10 Correct 7 ms 5120 KB Output is correct
11 Correct 89 ms 6048 KB Output is correct
12 Correct 7 ms 5120 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 124 ms 8448 KB Output is correct
2 Correct 128 ms 8636 KB Output is correct
3 Correct 133 ms 8448 KB Output is correct
4 Correct 130 ms 8448 KB Output is correct
5 Correct 125 ms 8448 KB Output is correct
6 Correct 7 ms 4352 KB Output is correct
7 Correct 6 ms 4352 KB Output is correct
8 Correct 6 ms 4352 KB Output is correct
9 Correct 616 ms 8568 KB Output is correct
10 Correct 7 ms 4608 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 142 ms 211448 KB Output is correct
2 Correct 141 ms 211576 KB Output is correct
3 Correct 156 ms 211576 KB Output is correct
4 Correct 188 ms 213096 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 123 ms 8448 KB Output is correct
2 Correct 131 ms 8448 KB Output is correct
3 Correct 136 ms 8448 KB Output is correct
4 Correct 134 ms 8568 KB Output is correct
5 Correct 129 ms 8576 KB Output is correct
6 Correct 138 ms 211576 KB Output is correct
7 Correct 144 ms 211576 KB Output is correct
8 Correct 159 ms 211712 KB Output is correct
9 Correct 180 ms 212984 KB Output is correct
10 Correct 136 ms 207608 KB Output is correct
11 Correct 138 ms 207608 KB Output is correct
12 Correct 227 ms 210424 KB Output is correct
13 Correct 150 ms 207608 KB Output is correct
14 Correct 139 ms 207608 KB Output is correct
15 Correct 7 ms 4480 KB Output is correct
16 Correct 6 ms 4352 KB Output is correct
17 Correct 6 ms 4352 KB Output is correct
18 Correct 7 ms 5120 KB Output is correct
19 Correct 7 ms 5120 KB Output is correct
20 Correct 7 ms 5120 KB Output is correct
21 Correct 7 ms 5120 KB Output is correct
22 Correct 7 ms 5120 KB Output is correct
23 Correct 7 ms 5120 KB Output is correct
24 Correct 7 ms 5120 KB Output is correct
25 Correct 88 ms 7544 KB Output is correct
26 Correct 7 ms 5120 KB Output is correct
27 Correct 601 ms 8568 KB Output is correct
28 Correct 1753 ms 215800 KB Output is correct
29 Correct 1646 ms 178040 KB Output is correct
30 Correct 1647 ms 178424 KB Output is correct
31 Correct 1836 ms 217720 KB Output is correct
32 Correct 7 ms 4352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 123 ms 8448 KB Output is correct
2 Correct 131 ms 8568 KB Output is correct
3 Correct 131 ms 8576 KB Output is correct
4 Correct 129 ms 8448 KB Output is correct
5 Correct 126 ms 8576 KB Output is correct
6 Correct 145 ms 211708 KB Output is correct
7 Correct 140 ms 211576 KB Output is correct
8 Correct 155 ms 211576 KB Output is correct
9 Correct 180 ms 213112 KB Output is correct
10 Correct 135 ms 207608 KB Output is correct
11 Correct 136 ms 207608 KB Output is correct
12 Correct 223 ms 210424 KB Output is correct
13 Correct 154 ms 207736 KB Output is correct
14 Correct 140 ms 207608 KB Output is correct
15 Correct 1810 ms 221480 KB Output is correct
16 Correct 8194 ms 222696 KB Output is correct
17 Correct 6 ms 4352 KB Output is correct
18 Correct 6 ms 4352 KB Output is correct
19 Correct 6 ms 4480 KB Output is correct
20 Correct 7 ms 5120 KB Output is correct
21 Correct 7 ms 5120 KB Output is correct
22 Correct 7 ms 5120 KB Output is correct
23 Correct 7 ms 5040 KB Output is correct
24 Correct 7 ms 5120 KB Output is correct
25 Correct 7 ms 5120 KB Output is correct
26 Correct 7 ms 5120 KB Output is correct
27 Correct 88 ms 7416 KB Output is correct
28 Correct 7 ms 5120 KB Output is correct
29 Correct 622 ms 8568 KB Output is correct
30 Correct 1766 ms 215872 KB Output is correct
31 Correct 8080 ms 219984 KB Output is correct
32 Correct 8021 ms 220052 KB Output is correct
33 Correct 1619 ms 178236 KB Output is correct
34 Correct 7473 ms 182180 KB Output is correct
35 Correct 1655 ms 178164 KB Output is correct
36 Correct 7545 ms 182412 KB Output is correct
37 Correct 1821 ms 217600 KB Output is correct
38 Correct 8074 ms 220680 KB Output is correct
39 Correct 7 ms 4480 KB Output is correct
40 Correct 7578 ms 182284 KB Output is correct