답안 #94295

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
94295 2019-01-17T11:45:17 Z fjzzq2002 웜뱃 (IOI13_wombats) C++14
16 / 100
20000 ms 16248 KB
#include "wombats.h"
#include <bits/stdc++.h>
using namespace std;
int n,m,r[5000][200],d[5000][200];
void cmin(int&a,int b) {if(a>b)a=b;}
struct ini
{
int s[200][200];
bool go;
};
ini gen(int t)
{
	//r[t],r[t+1],d[t]
	ini u; u.go=1;
	for(int i=0;i<m;++i)
	{
		u.s[i][i]=d[t][i];
		for(int j=i;j+1<m;++j)
			u.s[i][j+1]=u.s[i][j]+r[t+1][j];
		for(int j=i-1;j>=0;--j)
			u.s[i][j]=u.s[i][j+1]+r[t+1][j];
	}
	for(int i=0;i<m;++i)
	{
		for(int j=0;j+1<m;++j)
			cmin(u.s[j+1][i],u.s[j][i]+r[t][j]);
		for(int j=m-2;j>=0;--j)
			cmin(u.s[j][i],u.s[j+1][i]+r[t][j]);
	}
	return u;
}
ini*A,*B,*C; int X;
void go(int l,int r,int ql,int qr)
{
	if(l>r) return;
	int m=(l+r)/2,mi=2.1e9,ms;
	for(int t=ql;t<=qr;++t)
	{
		int v=A->s[X][t]+B->s[t][m];
		if(v<mi) mi=v,ms=t;
	}
	C->s[X][m]=mi;
	go(l,m-1,ql,ms);
	go(m+1,r,ms,qr);
}
ini operator * (ini&a,ini&b)
{
	if(!a.go) return b;
	if(!b.go) return a;
	ini u; u.go=1;
	A=&a,B=&b,C=&u;
	for(int i=0;i<m;++i)
		X=i,go(0,m-1,0,m-1);
	return u;
}
void init(int R, int C, int H[5000][200], int V[5000][200]) {
    n=R; m=C;
    memcpy(r,H,sizeof r);
    memcpy(d,V,sizeof d);
}

void changeH(int P, int Q, int W) {
	r[P][Q]=W;
}

void changeV(int P, int Q, int W) {
	d[P][Q]=W;
}

int escape(int V1, int V2) {
	ini x; x.go=0;
	for(int t=0;t<n-1;++t)
	{
		auto u=gen(t);
		x=x*u;
	}
	return x.s[V1][V2];
}

//prototype.

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 go(int, int, int, int)':
wombats.cpp:43:4: warning: 'ms' may be used uninitialized in this function [-Wmaybe-uninitialized]
  go(l,m-1,ql,ms);
  ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 20040 ms 12408 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 8440 KB Output is correct
2 Correct 15 ms 8440 KB Output is correct
3 Correct 10 ms 8568 KB Output is correct
4 Correct 215 ms 8568 KB Output is correct
5 Correct 200 ms 8568 KB Output is correct
6 Correct 213 ms 8696 KB Output is correct
7 Correct 204 ms 8568 KB Output is correct
8 Correct 198 ms 8592 KB Output is correct
9 Correct 221 ms 8584 KB Output is correct
10 Correct 216 ms 8592 KB Output is correct
11 Execution timed out 20054 ms 9080 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3298 ms 8844 KB Output is correct
2 Correct 1848 ms 8924 KB Output is correct
3 Correct 3355 ms 8952 KB Output is correct
4 Correct 3284 ms 8848 KB Output is correct
5 Correct 3307 ms 8844 KB Output is correct
6 Correct 10 ms 8568 KB Output is correct
7 Correct 9 ms 8440 KB Output is correct
8 Correct 10 ms 8440 KB Output is correct
9 Correct 2061 ms 8876 KB Output is correct
10 Correct 11 ms 8568 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 20005 ms 16248 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3264 ms 8848 KB Output is correct
2 Correct 1800 ms 8840 KB Output is correct
3 Correct 3276 ms 8952 KB Output is correct
4 Correct 3278 ms 8844 KB Output is correct
5 Correct 3252 ms 8856 KB Output is correct
6 Execution timed out 20016 ms 16248 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3158 ms 8824 KB Output is correct
2 Correct 1849 ms 8824 KB Output is correct
3 Correct 3348 ms 8952 KB Output is correct
4 Correct 3359 ms 8952 KB Output is correct
5 Correct 3335 ms 8824 KB Output is correct
6 Execution timed out 20062 ms 16248 KB Time limit exceeded
7 Halted 0 ms 0 KB -