답안 #94301

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
94301 2019-01-17T12:05:29 Z fjzzq2002 웜뱃 (IOI13_wombats) C++14
76 / 100
20000 ms 37756 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;
}ts[73],aa;
const int B=71;
const int M=8192;
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;
}
namespace GG
{
const ini*A,*B;
ini *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 * (const ini&a,const ini&b)
{
	using namespace GG;
	if(!a.go) return b;
	if(!b.go) return a;
	ini u; u.go=1;
	A=&a,
	GG::B=&b,C=&u;
	for(int i=0;i<m;++i)
		X=i,go(0,m-1,0,m-1);
	return u;
}
void reb(int b)
{
	ts[b].go=0;
	for(int t=b*B;t<=n-2&&t<(b+1)*B;++t)
		ts[b]=ts[b]*gen(t);
}
void reb()
{
	aa.go=0;
	for(int i=0;i<=(n-2)/B;++i)
		aa=aa*ts[i];
}
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);
    for(int i=0;i<=(n-2)/B;++i) reb(i);
    reb();
}
void changeH(int P, int Q, int W) {
	r[P][Q]=W;
	reb(P/B);
	if(P-1>=0&&P/B!=(P-1)/B)
		reb((P-1)/B);
	reb();
}

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

int escape(int V1, int V2) {
	return aa.s[V1][V2];
}

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 GG::go(int, int, int, int)':
wombats.cpp:48:4: warning: 'ms' may be used uninitialized in this function [-Wmaybe-uninitialized]
  go(l,m-1,ql,ms);
  ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1809 ms 23720 KB Output is correct
2 Correct 1835 ms 23772 KB Output is correct
3 Correct 1866 ms 26488 KB Output is correct
4 Correct 1804 ms 23772 KB Output is correct
5 Correct 1779 ms 23672 KB Output is correct
6 Correct 10 ms 8812 KB Output is correct
7 Correct 10 ms 8824 KB Output is correct
8 Correct 10 ms 8828 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 8828 KB Output is correct
2 Correct 10 ms 8824 KB Output is correct
3 Correct 10 ms 8824 KB Output is correct
4 Correct 12 ms 8824 KB Output is correct
5 Correct 11 ms 8824 KB Output is correct
6 Correct 11 ms 8824 KB Output is correct
7 Correct 11 ms 8824 KB Output is correct
8 Correct 11 ms 8824 KB Output is correct
9 Correct 11 ms 8824 KB Output is correct
10 Correct 11 ms 8824 KB Output is correct
11 Correct 74 ms 11260 KB Output is correct
12 Correct 11 ms 8824 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 938 ms 9436 KB Output is correct
2 Correct 1393 ms 9208 KB Output is correct
3 Correct 2114 ms 9340 KB Output is correct
4 Correct 2070 ms 9348 KB Output is correct
5 Correct 2416 ms 9336 KB Output is correct
6 Correct 9 ms 8828 KB Output is correct
7 Correct 9 ms 8824 KB Output is correct
8 Correct 9 ms 8824 KB Output is correct
9 Correct 7610 ms 9336 KB Output is correct
10 Correct 11 ms 8824 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1815 ms 27896 KB Output is correct
2 Correct 1807 ms 27628 KB Output is correct
3 Correct 1802 ms 27640 KB Output is correct
4 Correct 1861 ms 29304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 921 ms 9440 KB Output is correct
2 Correct 1350 ms 9212 KB Output is correct
3 Correct 2102 ms 9336 KB Output is correct
4 Correct 1910 ms 9208 KB Output is correct
5 Correct 2338 ms 9464 KB Output is correct
6 Correct 1811 ms 27768 KB Output is correct
7 Correct 1748 ms 27784 KB Output is correct
8 Correct 1749 ms 27768 KB Output is correct
9 Correct 1904 ms 29100 KB Output is correct
10 Correct 1776 ms 23768 KB Output is correct
11 Correct 1866 ms 23800 KB Output is correct
12 Correct 1838 ms 26484 KB Output is correct
13 Correct 1804 ms 23772 KB Output is correct
14 Correct 1833 ms 23800 KB Output is correct
15 Correct 9 ms 8824 KB Output is correct
16 Correct 11 ms 8824 KB Output is correct
17 Correct 10 ms 8824 KB Output is correct
18 Correct 21 ms 8824 KB Output is correct
19 Correct 11 ms 8824 KB Output is correct
20 Correct 11 ms 8824 KB Output is correct
21 Correct 11 ms 8824 KB Output is correct
22 Correct 11 ms 8828 KB Output is correct
23 Correct 12 ms 8824 KB Output is correct
24 Correct 11 ms 8824 KB Output is correct
25 Correct 75 ms 11256 KB Output is correct
26 Correct 11 ms 8824 KB Output is correct
27 Correct 7495 ms 9340 KB Output is correct
28 Correct 14140 ms 32060 KB Output is correct
29 Correct 18892 ms 28452 KB Output is correct
30 Correct 18788 ms 28212 KB Output is correct
31 Correct 15449 ms 33536 KB Output is correct
32 Correct 10 ms 8824 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 921 ms 9460 KB Output is correct
2 Correct 1338 ms 9340 KB Output is correct
3 Correct 2039 ms 9336 KB Output is correct
4 Correct 1861 ms 9464 KB Output is correct
5 Correct 2346 ms 9312 KB Output is correct
6 Correct 1805 ms 27768 KB Output is correct
7 Correct 1816 ms 27640 KB Output is correct
8 Correct 1811 ms 27644 KB Output is correct
9 Correct 1855 ms 29080 KB Output is correct
10 Correct 1768 ms 23848 KB Output is correct
11 Correct 1774 ms 23672 KB Output is correct
12 Correct 1830 ms 26488 KB Output is correct
13 Correct 1808 ms 23672 KB Output is correct
14 Correct 1805 ms 23676 KB Output is correct
15 Correct 4353 ms 37756 KB Output is correct
16 Execution timed out 20076 ms 36268 KB Time limit exceeded
17 Halted 0 ms 0 KB -