답안 #126152

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
126152 2019-07-07T06:13:35 Z nxteru 웜뱃 (IOI13_wombats) C++14
100 / 100
8122 ms 98728 KB
#include "wombats.h"
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000001
#define B 20
struct node{
	int n,d[200][200];
	void ini(int x){
		n=x;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(i==j)d[i][j]=0;
				else d[i][j]=INF;
			}
		}
	}
	node plus(node &q){
		node res;
		res.ini(n);
		int a[205][205],s;
		for(int i=n-1;i>-n;i--){
			for(int j=max(-i,0);i+j<n&&j<n;j++){
				s=INF;
				int x,y;
				if(j-1>=0)x=a[i+j][j-1];
				else x=0;
				if(i+j+1<n)y=a[i+j+1][j];
				else y=n-1;
				for(int k=x;k<=y;k++){
					if(d[i+j][k]+q.d[k][j]<s){
						x=k;
						s=d[i+j][k]+q.d[k][j];
					}
				}
				a[i+j][j]=x;
				res.d[i+j][j]=min(s,INF);
			}
		}
		return res;
	}
};
struct SEG{
	int n;
	node seg[1<<9];
	void ini(int x){
		n=x;
		for(int i=0;i<1<<9;i++)seg[i].ini(n);
	}
	void up(int a,node &q){
		a+=(1<<8)-1;
		seg[a]=q;
		while(a>0){
			a=(a-1)/2;
			seg[a]=seg[a*2+1].plus(seg[a*2+2]);
		}
	}
};
int h[5005][205],w[5005][205],n,m,p[205][205];
SEG s;
void change(int x){
	x=x/B;
	for(int i=0;i<m;i++){
		for(int j=0;j<m;j++){
			if(i==j)p[i][j]=0;
			else p[i][j]=INF;
		}
	}
	for(int i=0;i<B&&x*B+i<n;i++){
		for(int j=0;j<m;j++){
			int *q=p[j];
			for(int k=1;k<m;k++)q[k]=min(q[k],q[k-1]+h[x*B+i][k-1]);
			for(int k=m-2;k>=0;k--)q[k]=min(q[k],q[k+1]+h[x*B+i][k]);
			for(int k=0;k<m;k++)q[k]+=w[x*B+i][k];
		}
	}
	node res;
	res.n=m;
	for(int i=0;i<m;i++)for(int j=0;j<m;j++)res.d[i][j]=p[i][j];
	s.up(x,res);
}
void init(int R, int C, int H[5000][200], int V[5000][200]) {
   n=R,m=C;
   s.ini(m);
   for(int i=0;i<n;i++)for(int j=0;j<m-1;j++)h[i][j]=H[i][j];
   for(int i=0;i<n-1;i++)for(int j=0;j<m;j++)w[i][j]=V[i][j];
   for(int i=0;i<n;i+=B)change(i);
}
void changeH(int a, int b, int x) {
    h[a][b]=x;
    change(a);
}
 
void changeV(int a, int b, int x) {
    w[a][b]=x;
    change(a);
}
 
int escape(int a, int b) {
    return s.seg[0].d[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;
      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 174 ms 86864 KB Output is correct
2 Correct 169 ms 86692 KB Output is correct
3 Correct 228 ms 88360 KB Output is correct
4 Correct 181 ms 86776 KB Output is correct
5 Correct 157 ms 86776 KB Output is correct
6 Correct 5 ms 3960 KB Output is correct
7 Correct 5 ms 3960 KB Output is correct
8 Correct 5 ms 3960 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 3964 KB Output is correct
2 Correct 5 ms 3960 KB Output is correct
3 Correct 5 ms 3960 KB Output is correct
4 Correct 11 ms 11612 KB Output is correct
5 Correct 11 ms 11512 KB Output is correct
6 Correct 13 ms 11512 KB Output is correct
7 Correct 11 ms 11512 KB Output is correct
8 Correct 10 ms 11128 KB Output is correct
9 Correct 11 ms 11640 KB Output is correct
10 Correct 11 ms 11128 KB Output is correct
11 Correct 87 ms 12620 KB Output is correct
12 Correct 11 ms 11512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 309 ms 44228 KB Output is correct
2 Correct 304 ms 43896 KB Output is correct
3 Correct 317 ms 44152 KB Output is correct
4 Correct 316 ms 44280 KB Output is correct
5 Correct 311 ms 43896 KB Output is correct
6 Correct 5 ms 3960 KB Output is correct
7 Correct 5 ms 3960 KB Output is correct
8 Correct 5 ms 3964 KB Output is correct
9 Correct 1324 ms 44252 KB Output is correct
10 Correct 6 ms 5112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 171 ms 94732 KB Output is correct
2 Correct 167 ms 94728 KB Output is correct
3 Correct 183 ms 94728 KB Output is correct
4 Correct 206 ms 95740 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 314 ms 44300 KB Output is correct
2 Correct 304 ms 43972 KB Output is correct
3 Correct 317 ms 44152 KB Output is correct
4 Correct 318 ms 44152 KB Output is correct
5 Correct 313 ms 43896 KB Output is correct
6 Correct 170 ms 94712 KB Output is correct
7 Correct 169 ms 94820 KB Output is correct
8 Correct 184 ms 94712 KB Output is correct
9 Correct 208 ms 95588 KB Output is correct
10 Correct 161 ms 86792 KB Output is correct
11 Correct 160 ms 86728 KB Output is correct
12 Correct 228 ms 88360 KB Output is correct
13 Correct 174 ms 86872 KB Output is correct
14 Correct 160 ms 86776 KB Output is correct
15 Correct 5 ms 3960 KB Output is correct
16 Correct 5 ms 3960 KB Output is correct
17 Correct 5 ms 3860 KB Output is correct
18 Correct 11 ms 11512 KB Output is correct
19 Correct 11 ms 11512 KB Output is correct
20 Correct 11 ms 11512 KB Output is correct
21 Correct 11 ms 11512 KB Output is correct
22 Correct 11 ms 11128 KB Output is correct
23 Correct 11 ms 11512 KB Output is correct
24 Correct 10 ms 11128 KB Output is correct
25 Correct 88 ms 12536 KB Output is correct
26 Correct 11 ms 11640 KB Output is correct
27 Correct 1333 ms 44124 KB Output is correct
28 Correct 2145 ms 96248 KB Output is correct
29 Correct 2071 ms 87060 KB Output is correct
30 Correct 2108 ms 86904 KB Output is correct
31 Correct 2258 ms 97380 KB Output is correct
32 Correct 7 ms 5112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 312 ms 44152 KB Output is correct
2 Correct 302 ms 43896 KB Output is correct
3 Correct 318 ms 44280 KB Output is correct
4 Correct 318 ms 44152 KB Output is correct
5 Correct 317 ms 43896 KB Output is correct
6 Correct 170 ms 94696 KB Output is correct
7 Correct 166 ms 94896 KB Output is correct
8 Correct 184 ms 94712 KB Output is correct
9 Correct 213 ms 95560 KB Output is correct
10 Correct 161 ms 86776 KB Output is correct
11 Correct 161 ms 86748 KB Output is correct
12 Correct 236 ms 88380 KB Output is correct
13 Correct 196 ms 86860 KB Output is correct
14 Correct 159 ms 86800 KB Output is correct
15 Correct 2906 ms 97112 KB Output is correct
16 Correct 8122 ms 98728 KB Output is correct
17 Correct 5 ms 3960 KB Output is correct
18 Correct 5 ms 3880 KB Output is correct
19 Correct 5 ms 3960 KB Output is correct
20 Correct 11 ms 11516 KB Output is correct
21 Correct 11 ms 11512 KB Output is correct
22 Correct 11 ms 11512 KB Output is correct
23 Correct 11 ms 11512 KB Output is correct
24 Correct 11 ms 11128 KB Output is correct
25 Correct 11 ms 11512 KB Output is correct
26 Correct 11 ms 11128 KB Output is correct
27 Correct 87 ms 12536 KB Output is correct
28 Correct 11 ms 11512 KB Output is correct
29 Correct 1337 ms 44280 KB Output is correct
30 Correct 2156 ms 96352 KB Output is correct
31 Correct 7744 ms 97844 KB Output is correct
32 Correct 7735 ms 97756 KB Output is correct
33 Correct 2079 ms 86928 KB Output is correct
34 Correct 7694 ms 95144 KB Output is correct
35 Correct 2096 ms 86944 KB Output is correct
36 Correct 7721 ms 94996 KB Output is correct
37 Correct 2202 ms 97352 KB Output is correct
38 Correct 7940 ms 98520 KB Output is correct
39 Correct 6 ms 5112 KB Output is correct
40 Correct 7975 ms 95016 KB Output is correct