QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#402120#4370. Road Times321625TL 293ms2192kbC++143.0kb2024-04-29 22:15:102024-04-29 22:15:10

Judging History

你现在查看的是最新测评结果

  • [2024-04-29 22:15:10]
  • 评测
  • 测评结果:TL
  • 用时:293ms
  • 内存:2192kb
  • [2024-04-29 22:15:10]
  • 提交

answer

#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
typedef double ld;
namespace simplex
{
const int N=107,M=307;
const ld eps=1e-5;
inline int sgn(ld x){return (-eps<=x&&x<=eps)?0:(x>0?1:-1);}
int n,m;ld a[M][N],b[M][N];int id[N+M];
void pivot(int e,int l)
{
//	printf(" pivot %d %d\n",e,l);
	std::swap(id[n+l],id[e]);
	ld kk=-a[l][e];a[l][e]=-1;
	for(int j=0;j<=n;++j)a[l][j]/=kk;
	for(int i=0;i<=m;++i)if(i!=l&&sgn(a[i][e]))
	{
		ld coef=a[i][e];a[i][e]=0;
		for(int k=0;k<=n;++k)a[i][k]+=coef*a[l][k];
	}
}
ld simplex(int _n,int _m)
{
//	puts("simplex");
	n=_n;m=_m;memcpy(a+1,b+1,m*sizeof*b);
	for(int i=1;i<=n+m;++i)id[i]=i;
	while(1)
	{
		int e=0,l=0;
		for(int i=1;i<=m;++i)if(sgn(a[i][0])<0&&(!l||a[i][0]<a[l][0]))l=i;
		if(!l)break;for(int i=1;i<=n;++i)if(sgn(a[l][i])>0&&id[i]>id[e])e=i;
		pivot(e,l);
	}
	while(1)
	{
		int e=0,l=0;
		for(int i=1;i<=n;++i)if(sgn(a[0][i])>0&&(!e||a[0][e]<a[0][i]))e=i;
		if(!e)return **a;
		for(int i=1;i<=m;++i)
			if(sgn(a[i][e])<0)
			{
				if(!l){l=i;continue;}
				ld crs=a[l][0]*a[i][e]-a[i][0]*a[l][e];
				if(sgn(crs)<0||(!sgn(crs)&&id[i]>id[l]))l=i;
			}
		pivot(e,l);
	}
}
}
const int N=37,M=107;
struct pii{int v,w;};bool vis[N];int d[N][N];
bool operator<(pii x,pii y){return x.w>y.w;}
void dijkstra(int s,int n,int*dis,int*pre)
{
	memset(dis,0x3f,N<<2);memset(vis,0,N);
	dis[s]=pre[s]=0;//printf("s=%d\n",s);
	while(1)
	{
	    int p=0;for(int i=1;i<=n;++i)if(!vis[i]&&(!p||dis[i]<dis[p]))p=i;
	    if(!p)return;vis[p]=1;for(int j=1;j<=n;++j)if(dis[j]>dis[p]+d[p][j])dis[j]=dis[p]+d[p][j],pre[j]=p;//,printf("pr[%d]=%d\n",j,pre[j]);
	}
}
int id[N][N],pre[N][N],dis[N][N];
int ds[M];
int main()
{
//	freopen("39-random20.in","r",stdin);
	int n,m=0;scanf("%d",&n);
	for(int i=1;i<=n;++i)for(int j=1;j<=n;++j)
	{
		scanf("%d",d[i]+j);
		if(i!=j&&d[i][j]!=-1)ds[id[i][j]=++m]=d[i][j];
		else if(d[i][j]==-1)d[i][j]=0x3f3f3f3f;
	}
	for(int i=1;i<=n;++i)dijkstra(i,n,dis[i],pre[i]);
	for(int i=1;i<=m;++i)
	{
		simplex::b[i][0]=ds[i];
		simplex::b[i][i]=-1;
	}
	int ma,mb;scanf("%d",&ma);
	for(int i=1;i<=ma;++i)
	{
		int s,t,d;scanf("%d%d%d",&s,&t,&d);
		++s;++t;d-=dis[s][t];
		simplex::b[m+i+i-1][0]=d;
		simplex::b[m+i+i][0]=-d;
		for(int j=t;j!=s;j=pre[s][j])
		{
			int p=pre[s][j],ii=id[p][j];
//			printf("p=%d ii=%d\n",p,ii);
			simplex::b[m+i+i-1][ii]=-1;
			simplex::b[m+i+i][ii]=1;
		}
	}
	scanf("%d",&mb);
	for(int i=1;i<=mb;++i)
	{
		int s,t;scanf("%d%d",&s,&t);++s;++t;
		for(int j=0;j<=m;++j)simplex::a[0][j]=0;
		for(int j=t;j!=s;j=pre[s][j])
		{
			int p=pre[s][j],ii=id[p][j];
			simplex::a[0][ii]=-1;
		}
		ld mn=-simplex::simplex(m,m+ma*2)+dis[s][t];
		for(int j=0;j<=m;++j)simplex::a[0][j]=0;
		for(int j=t;j!=s;j=pre[s][j])
		{
			int p=pre[s][j],ii=id[p][j];
			simplex::a[0][ii]=1;
		}
		ld mx=simplex::simplex(m,m+ma*2)+dis[s][t];
		printf("%d %d %.8lf %.8lf\n",s-1,t-1,mn,mx);
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 1700kb

input:

3
0 50 -1
55 0 40
-1 40 0
1
0 2 120
3
0 1
1 2
1 0

output:

0 1 50.00000000 80.00000000
1 2 40.00000000 70.00000000
1 0 55.00000000 110.00000000

result:

ok 12 numbers

Test #2:

score: 0
Accepted
time: 0ms
memory: 1644kb

input:

3
0 50 -1
55 0 40
-1 40 0
1
0 2 90
3
0 1
1 2
1 0

output:

0 1 50.00000000 50.00000000
1 2 40.00000000 40.00000000
1 0 55.00000000 110.00000000

result:

ok 12 numbers

Test #3:

score: 0
Accepted
time: 0ms
memory: 1668kb

input:

3
0 50 -1
55 0 40
-1 40 0
1
0 2 180
3
0 1
1 2
1 0

output:

0 1 100.00000000 100.00000000
1 2 80.00000000 80.00000000
1 0 55.00000000 110.00000000

result:

ok 12 numbers

Test #4:

score: 0
Accepted
time: 0ms
memory: 1652kb

input:

6
0 960 -1 -1 -1 -1
-1 0 -1 -1 1000 -1
-1 1000 0 -1 -1 -1
-1 -1 -1 0 -1 -1
-1 -1 -1 1000 0 970
-1 -1 -1 -1 -1 0
3
0 3 5900
2 3 5800
2 5 5700
6
0 1
2 1
1 4
4 3
4 5
0 5

output:

0 1 1900.00000000 1920.00000000
2 1 1800.00000000 1820.00000000
1 4 1980.00000000 2000.00000000
4 3 1980.00000000 2000.00000000
4 5 1880.00000000 1900.00000000
0 5 5800.00000000 5800.00000000

result:

ok 24 numbers

Test #5:

score: 0
Accepted
time: 0ms
memory: 1664kb

input:

6
0 960 -1 -1 -1 -1
-1 0 -1 -1 1000 -1
-1 1000 0 -1 -1 -1
-1 -1 -1 0 -1 -1
-1 -1 -1 1000 0 940
-1 -1 -1 -1 -1 0
3
0 3 5900
2 3 5800
2 5 5700
6
0 1
2 1
1 4
4 3
4 5
0 5

output:

0 1 1920.00000000 1920.00000000
2 1 1820.00000000 1820.00000000
1 4 2000.00000000 2000.00000000
4 3 1980.00000000 1980.00000000
4 5 1880.00000000 1880.00000000
0 5 5800.00000000 5800.00000000

result:

ok 24 numbers

Test #6:

score: 0
Accepted
time: 0ms
memory: 1704kb

input:

6
0 950 -1 -1 -1 -1
-1 0 -1 -1 1000 -1
-1 1000 0 -1 -1 -1
-1 -1 -1 0 -1 -1
-1 -1 -1 1000 0 970
-1 -1 -1 -1 -1 0
3
0 3 5900
2 3 5800
2 5 5700
6
0 1
2 1
1 4
4 3
4 5
0 5

output:

0 1 1900.00000000 1900.00000000
2 1 1800.00000000 1800.00000000
1 4 2000.00000000 2000.00000000
4 3 2000.00000000 2000.00000000
4 5 1900.00000000 1900.00000000
0 5 5800.00000000 5800.00000000

result:

ok 24 numbers

Test #7:

score: 0
Accepted
time: 0ms
memory: 1696kb

input:

10
0 123 -1 -1 -1 -1 -1 -1 -1 -1
-1 0 234 -1 -1 -1 -1 -1 -1 -1
-1 -1 0 345 -1 -1 -1 -1 -1 -1
-1 -1 -1 0 456 -1 -1 -1 -1 -1
-1 -1 -1 -1 0 567 -1 -1 -1 -1
-1 -1 -1 -1 -1 0 678 -1 -1 -1
-1 -1 -1 -1 -1 -1 0 890 -1 -1
-1 -1 -1 -1 -1 -1 -1 0 901 -1
-1 -1 -1 -1 -1 -1 -1 -1 0 555
666 -1 -1 -1 -1 -1 -1 -1 -1...

output:

0 0 0.00000000 0.00000000
0 1 216.00000000 246.00000000
0 2 450.00000000 714.00000000
0 3 1084.00000000 1114.00000000
0 4 1540.00000000 1570.00000000
0 5 2674.00000000 2704.00000000
0 6 3408.00000000 3438.00000000
0 7 4298.00000000 4358.00000000
0 8 5199.00000000 5542.00000000
0 9 5754.00000000 6097...

result:

ok 400 numbers

Test #8:

score: 0
Accepted
time: 0ms
memory: 1668kb

input:

10
0 123 -1 -1 -1 -1 -1 -1 -1 -1
-1 0 234 -1 -1 -1 -1 -1 -1 -1
-1 -1 0 345 -1 -1 -1 -1 -1 -1
-1 -1 -1 0 456 -1 -1 -1 -1 -1
-1 -1 -1 -1 0 567 -1 -1 -1 -1
-1 -1 -1 -1 -1 0 678 -1 -1 -1
-1 -1 -1 -1 -1 -1 0 890 -1 -1
-1 -1 -1 -1 -1 -1 -1 0 901 -1
-1 -1 -1 -1 -1 -1 -1 -1 0 555
666 -1 -1 -1 -1 -1 -1 -1 -1...

output:

0 0 0.00000000 0.00000000
0 1 216.00000000 246.00000000
0 2 580.00000000 640.00000000
0 3 1084.00000000 1114.00000000
0 4 1540.00000000 1570.00000000
0 5 2674.00000000 2704.00000000
0 6 3408.00000000 3438.00000000
0 7 4298.00000000 4358.00000000
0 8 5199.00000000 5542.00000000
0 9 5754.00000000 6097...

result:

ok 400 numbers

Test #9:

score: 0
Accepted
time: 0ms
memory: 1664kb

input:

10
0 123 -1 -1 -1 -1 -1 -1 -1 -1
-1 0 234 -1 -1 -1 -1 -1 -1 -1
-1 -1 0 345 -1 -1 -1 -1 -1 -1
-1 -1 -1 0 456 -1 -1 -1 -1 -1
-1 -1 -1 -1 0 567 -1 -1 -1 -1
-1 -1 -1 -1 -1 0 678 -1 -1 -1
-1 -1 -1 -1 -1 -1 0 890 -1 -1
-1 -1 -1 -1 -1 -1 -1 0 901 -1
-1 -1 -1 -1 -1 -1 -1 -1 0 555
666 -1 -1 -1 -1 -1 -1 -1 -1...

output:

0 0 0.00000000 0.00000000
0 1 245.00000000 246.00000000
0 2 609.00000000 640.00000000
0 3 1084.00000000 1114.00000000
0 4 1569.00000000 1570.00000000
0 5 2703.00000000 2704.00000000
0 6 3437.00000000 3438.00000000
0 7 4327.00000000 4358.00000000
0 8 5228.00000000 5541.00000000
0 9 5783.00000000 6097...

result:

ok 400 numbers

Test #10:

score: 0
Accepted
time: 0ms
memory: 1664kb

input:

3
0 10 -1
-1 0 10
10 -1 0
3
0 2 21
1 0 21
2 1 21
3
0 1
1 2
2 0

output:

0 1 10.50000000 10.50000000
1 2 10.50000000 10.50000000
2 0 10.50000000 10.50000000

result:

ok 12 numbers

Test #11:

score: 0
Accepted
time: 0ms
memory: 1732kb

input:

8
0 10 -1 -1 -1 -1 -1 -1
-1 0 10 -1 -1 -1 -1 -1
-1 -1 0 10 -1 -1 -1 -1
-1 -1 -1 0 10 -1 -1 -1
-1 -1 -1 -1 0 10 -1 -1
-1 -1 -1 -1 -1 0 10 -1
-1 -1 -1 -1 -1 -1 0 10
10 -1 -1 -1 -1 -1 -1 0
8
0 7 71
1 0 71
2 1 71
3 2 71
4 3 71
5 4 71
6 5 71
7 6 71
8
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 0

output:

0 1 10.14285714 10.14285714
1 2 10.14285714 10.14285714
2 3 10.14285714 10.14285714
3 4 10.14285714 10.14285714
4 5 10.14285714 10.14285714
5 6 10.14285714 10.14285714
6 7 10.14285714 10.14285714
7 0 10.14285714 10.14285714

result:

ok 32 numbers

Test #12:

score: 0
Accepted
time: 0ms
memory: 1648kb

input:

7
0 10 -1 -1 -1 -1 -1
-1 0 10 -1 -1 -1 -1
-1 -1 0 10 -1 -1 -1
-1 -1 -1 0 10 -1 -1
-1 -1 -1 -1 0 10 -1
-1 -1 -1 -1 -1 0 10
10 -1 -1 -1 -1 -1 0
6
0 4 41
1 5 41
2 6 41
3 0 41
5 2 41
6 3 41
7
0 1
1 2
2 3
3 4
4 5
5 6
6 0

output:

0 1 10.00000000 11.00000000
1 2 10.00000000 10.33333333
2 3 10.00000000 10.33333333
3 4 10.00000000 10.33333333
4 5 10.00000000 11.00000000
5 6 10.00000000 10.33333333
6 0 10.00000000 10.33333333

result:

ok 28 numbers

Test #13:

score: 0
Accepted
time: 8ms
memory: 1844kb

input:

30
0 392 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 0 -1 -1 -1 -1 -1 -1 -1 -1 793 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 0 -1 -1 -1 -1 750 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
703 -1 -1 0 -1 -1 -1 -1 -1 ...

output:

1 10 793.17241379 793.17241379
10 16 726.17241379 726.17241379
16 29 367.17241379 367.17241379
29 15 812.17241379 812.17241379
15 24 959.17241379 959.17241379
24 2 826.17241379 826.17241379
2 7 750.17241379 750.17241379
7 18 865.17241379 865.17241379
18 13 492.17241379 492.17241379
13 12 865.1724137...

result:

ok 400 numbers

Test #14:

score: 0
Accepted
time: 7ms
memory: 1788kb

input:

30
0 392 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 0 -1 -1 -1 -1 -1 -1 -1 -1 793 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 0 -1 -1 -1 -1 750 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
703 -1 -1 0 -1 -1 -1 -1 -1 ...

output:

1 10 793.00000000 793.17857143
10 16 726.00000000 726.17857143
16 29 367.00000000 367.17857143
29 15 812.00000000 812.17857143
15 24 959.00000000 959.17857143
24 2 826.00000000 826.17857143
2 7 750.00000000 750.17857143
7 18 865.00000000 865.17857143
18 13 492.00000000 492.17857143
13 12 865.0000000...

result:

ok 400 numbers

Test #15:

score: 0
Accepted
time: 1ms
memory: 1968kb

input:

1
0
100
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 ...

output:

0 0 0.00000000 0.00000000
0 0 0.00000000 0.00000000
0 0 0.00000000 0.00000000
0 0 0.00000000 0.00000000
0 0 0.00000000 0.00000000
0 0 0.00000000 0.00000000
0 0 0.00000000 0.00000000
0 0 0.00000000 0.00000000
0 0 0.00000000 0.00000000
0 0 0.00000000 0.00000000
0 0 0.00000000 0.00000000
0 0 0.00000000...

result:

ok 400 numbers

Test #16:

score: 0
Accepted
time: 1ms
memory: 2008kb

input:

30
0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 0 -1 -1 -1 -1 -1 -1 -...

output:

0 0 0.00000000 0.00000000
1 1 0.00000000 0.00000000
2 2 0.00000000 0.00000000
3 3 0.00000000 0.00000000
4 4 0.00000000 0.00000000
5 5 0.00000000 0.00000000
6 6 0.00000000 0.00000000
7 7 0.00000000 0.00000000
8 8 0.00000000 0.00000000
9 9 0.00000000 0.00000000
10 10 0.00000000 0.00000000
11 11 0.0000...

result:

ok 400 numbers

Test #17:

score: 0
Accepted
time: 2ms
memory: 1784kb

input:

30
0 1000 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
1000 0 1000 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 1000 0 1000 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 1000 0 1000 -1...

output:

0 29 58000.00000000 58000.00000000
6 11 10000.00000000 10000.00000000
7 16 18000.00000000 18000.00000000
26 6 20000.00000000 40000.00000000
3 12 18000.00000000 18000.00000000
6 25 38000.00000000 38000.00000000
17 0 17000.00000000 34000.00000000
25 27 4000.00000000 4000.00000000
22 2 20000.00000000 4...

result:

ok 400 numbers

Test #18:

score: 0
Accepted
time: 1ms
memory: 1744kb

input:

30
0 1000 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
1000 0 1000 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 1000 0 1000 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 1000 0 1000 -1...

output:

0 29 29000.00000000 29000.00000000
6 11 5000.00000000 5000.00000000
7 16 9000.00000000 9000.00000000
26 6 20000.00000000 40000.00000000
3 12 9000.00000000 9000.00000000
6 25 19000.00000000 19000.00000000
17 0 17000.00000000 34000.00000000
25 27 2000.00000000 2000.00000000
22 2 20000.00000000 40000.0...

result:

ok 400 numbers

Test #19:

score: 0
Accepted
time: 2ms
memory: 1740kb

input:

30
0 1000 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
1000 0 1000 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 1000 0 1000 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 1000 0 1000 -1...

output:

0 29 29000.00000000 29000.00000000
6 11 5000.00000000 5000.00000000
7 16 9000.00000000 9000.00000000
26 6 40000.00000000 40000.00000000
3 12 9000.00000000 9000.00000000
6 25 19000.00000000 19000.00000000
17 0 34000.00000000 34000.00000000
25 27 2000.00000000 2000.00000000
22 2 40000.00000000 40000.0...

result:

ok 400 numbers

Test #20:

score: 0
Accepted
time: 3ms
memory: 1764kb

input:

30
0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 298 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 342 -1 -1 -1 -1 -1 -1 -1 -1 533 -1 -1 -1 -1 -1
-1 -1 0 -1 -1 236 -1 -1 -1 -1 -1 -1 477 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 0 -1 -1 -1 -1 -1...

output:

8 29 1292.00000000 1310.00000000
14 4 1363.00000000 2642.00000000
14 7 1016.00000000 1948.00000000
21 28 236.00000000 472.00000000
0 20 2018.00000000 3428.00000000
2 1 5565.00000000 5896.00000000
9 26 5769.00000000 6091.00000000
4 20 1551.00000000 3102.00000000
10 6 498.00000000 996.00000000
24 19 2...

result:

ok 400 numbers

Test #21:

score: 0
Accepted
time: 3ms
memory: 1836kb

input:

30
0 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 3 -1
-1 -1 0 -1 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 0 -1 -1 -1 -1 -1 -1 -1 2 -...

output:

13 10 5.00000000 5.00000000
13 26 7.00000000 8.00000000
7 8 11.00000000 16.00000000
26 4 9.00000000 12.00000000
8 27 8.00000000 10.00000000
25 11 3.00000000 5.00000000
5 17 5.00000000 5.00000000
27 1 6.00000000 7.00000000
3 5 6.00000000 6.00000000
6 16 9.00000000 9.00000000
7 9 11.00000000 13.000000...

result:

ok 400 numbers

Test #22:

score: 0
Accepted
time: 15ms
memory: 1836kb

input:

30
0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 4 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 7 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 3 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 0 -1 -1 -1 -1 -1 -1 -1 1...

output:

7 29 28.00000000 31.00000000
0 16 56.00000000 57.00000000
21 8 16.50000000 19.00000000
5 11 31.00000000 33.00000000
17 1 58.00000000 59.00000000
19 16 55.00000000 55.00000000
8 28 46.00000000 46.00000000
10 14 8.00000000 14.00000000
16 24 67.00000000 67.00000000
29 14 11.00000000 18.00000000
24 0 42...

result:

ok 400 numbers

Test #23:

score: 0
Accepted
time: 23ms
memory: 1912kb

input:

30
0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 19 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 170 -1 -1 -1 -1 -1 -1 -1
-1 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 352 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 176 -1
-1 -1 -1 0 -1 -1 -1 -1 -1 -...

output:

3 14 491.00000000 491.00000000
15 10 936.00000000 1226.00000000
8 28 600.00000000 600.00000000
16 5 701.00000000 701.00000000
11 2 1583.00000000 1880.00000000
17 21 800.00000000 800.00000000
18 4 1421.00000000 1847.00000000
27 7 648.00000000 745.00000000
14 16 2942.00000000 2942.00000000
17 13 2255....

result:

ok 400 numbers

Test #24:

score: 0
Accepted
time: 43ms
memory: 1976kb

input:

30
0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 884 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 15 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 0 -1 -1 -1 -1 -1 171 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 0 -1 -1 -1 861 -1 -...

output:

2 27 4033.00000000 4033.00000000
17 16 6952.00000000 7034.00000000
2 20 1801.00000000 1801.00000000
5 19 2702.00000000 2702.00000000
20 23 5326.00000000 5326.00000000
11 0 5382.00000000 5382.00000000
9 22 5817.00000000 5974.00000000
8 9 7184.00000000 7314.00000000
26 16 7847.00000000 8792.00000000
2...

result:

ok 400 numbers

Test #25:

score: 0
Accepted
time: 123ms
memory: 2124kb

input:

30
0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 5 -1 -1 -1
-1 0 -1 -1 -1 -1 -1 -1 -1 4 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 10 -1
-1 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 4 -1
-1 -1 -1 0 -1 -1 -1 -1 -1 -1 -1 1...

output:

24 3 51.00000000 51.00000000
10 4 55.00000000 55.00000000
24 3 51.00000000 51.00000000
19 21 69.00000000 69.00000000
6 27 11.00000000 11.00000000
6 22 45.00000000 45.00000000
7 4 68.00000000 68.00000000
1 4 50.00000000 50.00000000
20 15 49.00000000 49.00000000
22 9 61.00000000 61.00000000
7 8 76.000...

result:

ok 400 numbers

Test #26:

score: 0
Accepted
time: 235ms
memory: 2052kb

input:

30
0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 130 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 523 -1 -1 72 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 513 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 0 -1 -1 -1 -1 -1 2...

output:

5 4 3296.00000000 3296.00000000
6 17 528.00000000 528.00000000
4 15 3951.00000000 3951.00000000
1 10 1500.00000000 1500.00000000
15 25 3213.00000000 3213.00000000
1 16 83.00000000 83.00000000
19 14 5247.00000000 5247.00000000
28 22 3127.00000000 3127.00000000
25 26 1464.00000000 1464.00000000
27 14 ...

result:

ok 400 numbers

Test #27:

score: 0
Accepted
time: 225ms
memory: 2052kb

input:

30
0 10 -1 -1 -1 -1 825 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
986 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 889 -1 -1 -1 -1 -1 -1 -1 721 -1 -1 -1 -1 -1
-1 -1 -1 0 -1 -1 -1 -1 -1 ...

output:

13 20 6819.00000000 6819.00000000
6 5 7003.00000000 7003.00000000
27 0 5367.00000000 5367.00000000
2 16 1307.00000000 1307.00000000
3 28 1965.00000000 1965.00000000
17 10 1442.00000000 1442.00000000
7 28 4092.00000000 4092.00000000
20 12 3446.00000000 3446.00000000
20 11 2954.00000000 2954.00000000
...

result:

ok 400 numbers

Test #28:

score: 0
Accepted
time: 2ms
memory: 1824kb

input:

30
0 -1 -1 -1 -1 -1 -1 60 -1 -1 -1 -1 614 -1 31 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 146 -1 -1 -1 -1
-1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 778 -1 -1
118 96 0 -1 -1 232 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 0 -1 -1 -1 -1 -1...

output:

6 19 2253.00000000 4506.00000000
12 23 802.00000000 1091.00000000
17 28 2804.00000000 3609.00000000
22 7 595.00000000 1190.00000000
27 10 1225.00000000 1658.00000000
7 29 861.00000000 1722.00000000
5 0 875.00000000 1687.00000000
16 26 1676.00000000 3126.00000000
20 28 591.00000000 1182.00000000
0 21...

result:

ok 400 numbers

Test #29:

score: 0
Accepted
time: 3ms
memory: 1900kb

input:

30
0 -1 -1 -1 -1 -1 347 -1 -1 -1 -1 -1 864 -1 -1 357 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 0 201 -1 -1 -1 -1 -1 -1 469 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 260 -1 -1 -1
-1 -1 0 -1 -1 -1 -1 -1 219 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 180 -1 837 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 0 -1 -1 108 ...

output:

28 18 999.00000000 1974.00000000
21 29 933.00000000 1805.00000000
21 20 434.00000000 868.00000000
22 28 1915.00000000 3144.00000000
11 23 877.00000000 1754.00000000
25 13 1033.00000000 1110.00000000
11 8 405.00000000 810.00000000
23 19 968.00000000 1936.00000000
24 26 100.00000000 193.00000000
1 6 9...

result:

ok 400 numbers

Test #30:

score: 0
Accepted
time: 5ms
memory: 1928kb

input:

30
0 -1 -1 -1 -1 254 -1 -1 -1 -1 -1 -1 -1 -1 -1 185 -1 -1 -1 168 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 0 -1 -1 258 98 -1 -1 -1 -1 -1 -1 437 -1 -1 -1 166 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 347 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 221 -1 -1 -1 -1
-1 -1 -1 0 -1 -1 -1 43...

output:

22 22 0.00000000 0.00000000
9 16 25.00000000 47.00000000
25 5 526.00000000 1037.00000000
8 24 494.00000000 586.00000000
10 23 935.00000000 1405.00000000
13 20 411.00000000 411.00000000
7 11 792.00000000 1472.00000000
6 26 781.00000000 1233.00000000
29 7 356.00000000 672.00000000
28 12 353.00000000 7...

result:

ok 400 numbers

Test #31:

score: 0
Accepted
time: 12ms
memory: 1892kb

input:

30
0 -1 -1 -1 3 -1 2 -1 -1 -1 6 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 6 -1 5 -1 -1
-1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 10 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 0 -1 -1 -1 5 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 2 -1 8 -1 -1 -1
1 2 -1 0 -1 -1 -1 -1 4 -1 -1 -1 -1 -1 -...

output:

8 15 19.00000000 19.00000000
7 18 17.00000000 21.00000000
10 15 15.00000000 16.00000000
10 7 11.00000000 22.00000000
25 13 18.00000000 20.00000000
29 15 3.00000000 4.00000000
11 5 8.00000000 8.00000000
28 12 24.00000000 25.00000000
5 19 22.00000000 31.00000000
0 24 7.00000000 10.00000000
17 20 15.00...

result:

ok 400 numbers

Test #32:

score: 0
Accepted
time: 35ms
memory: 2004kb

input:

30
0 592 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 76 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 605
-1 0 -1 -1 -1 412 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 0 -1 201 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 531 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
873 -1 -1 0 -1 -1 -1 -1 -...

output:

6 26 684.00000000 1368.00000000
12 25 2584.00000000 2584.00000000
17 23 1273.00000000 1307.00000000
13 2 913.00000000 947.00000000
8 16 500.00000000 572.00000000
25 19 2299.00000000 2299.00000000
14 4 1418.00000000 1418.00000000
23 17 3155.00000000 3155.00000000
4 9 738.00000000 738.00000000
29 25 2...

result:

ok 400 numbers

Test #33:

score: 0
Accepted
time: 211ms
memory: 2056kb

input:

30
0 -1 196 -1 -1 -1 229 -1 -1 -1 -1 -1 -1 -1 -1 457 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 499 -1 -1
-1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 6 -1 -1 534 -1 -1 808 -1 788 -1 324 -1 -1 -1 -1
-1 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 475 -1 -1 -1 -1 -1 384 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 58 -1 0 -1 -1 -1 -...

output:

3 14 1088.00000000 1088.00000000
12 28 1072.00000000 1272.00000000
15 24 1976.00000000 1976.00000000
4 12 1025.00000000 1301.00000000
18 3 2082.00000000 2082.00000000
5 20 855.00000000 1236.00000000
2 6 994.00000000 1409.00000000
27 19 2924.00000000 2924.00000000
21 13 277.00000000 277.00000000
23 7...

result:

ok 400 numbers

Test #34:

score: 0
Accepted
time: 11ms
memory: 2192kb

input:

30
0 -1 -1 -1 -1 -1 -1 -1 -1 1 2 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1
-1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 2 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1
-1 -1 0 -1 -1 1 -1 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 0 -1 1 1 -1 -1 1 -1 -1 -1 -1...

output:

15 4 4.00000000 7.00000000
18 19 3.00000000 3.00000000
26 26 0.00000000 0.00000000
18 17 5.00000000 5.00000000
2 19 6.00000000 6.00000000
10 2 4.00000000 4.00000000
16 21 3.00000000 3.00000000
23 28 1.00000000 2.00000000
24 14 4.00000000 4.00000000
4 25 5.00000000 5.00000000
20 29 2.00000000 4.00000...

result:

ok 400 numbers

Test #35:

score: 0
Accepted
time: 52ms
memory: 2180kb

input:

30
0 -1 -1 -1 -1 -1 -1 -1 -1 1 2 -1 -1 2 1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 -1
-1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 2 -1 -1 2 -1 -1 -1 -1 -1 -1 1 -1
-1 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 0 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...

output:

5 28 6.00000000 7.00000000
5 29 4.00000000 7.00000000
23 3 8.00000000 11.00000000
11 10 4.00000000 4.00000000
27 4 4.00000000 4.00000000
5 0 5.00000000 5.00000000
21 21 0.00000000 0.00000000
29 27 6.00000000 6.00000000
7 17 6.00000000 6.00000000
21 21 0.00000000 0.00000000
0 5 5.00000000 5.00000000
...

result:

ok 400 numbers

Test #36:

score: 0
Accepted
time: 33ms
memory: 2140kb

input:

30
0 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 3 3 -1 -1 -1 -1 -1 -1
-1 0 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 2 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 0 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 1 3 -1 -1 -1 -1 -1 5 -1 -1 -1 3 -1 -1 -1 -1
-1 -1 -1 0 -1 -1 -1 -1 5 -1 5 -1 -1 -1 -1...

output:

27 11 11.00000000 11.00000000
25 6 4.00000000 4.00000000
6 12 13.00000000 13.00000000
20 23 9.00000000 9.00000000
4 12 14.00000000 14.00000000
23 23 0.00000000 0.00000000
15 9 3.00000000 3.00000000
0 28 6.00000000 6.00000000
7 29 3.00000000 3.00000000
8 16 13.00000000 13.00000000
25 0 8.00000000 8.0...

result:

ok 400 numbers

Test #37:

score: 0
Accepted
time: 102ms
memory: 2136kb

input:

30
0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 5 -1 -1 7 -1 -1 3 -1 -1 -1 -1 -1 8
-1 0 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 8 -1 -1 -1 -1 -1 2 -1 -1
-1 -1 0 -1 -1 -1 -1 -1 -1 9 -1 -1 -1 -1 -1 -1 -1 -1 -1 5 -1 4 -1 -1 -1 2 3 -1 -1 -1
-1 -1 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -...

output:

19 24 13.00000000 15.00000000
22 2 8.00000000 8.00000000
20 4 12.00000000 12.00000000
9 27 4.00000000 4.00000000
21 6 10.00000000 11.00000000
13 17 7.00000000 7.00000000
28 9 3.00000000 3.00000000
16 13 16.00000000 16.00000000
9 4 8.00000000 8.00000000
4 24 10.00000000 12.00000000
5 28 11.00000000 1...

result:

ok 400 numbers

Test #38:

score: 0
Accepted
time: 293ms
memory: 2152kb

input:

30
0 -1 -1 -1 9 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 14 -1 7 9 -1 -1 -1 11 -1 -1 -1 -1 -1 -1
-1 0 -1 -1 -1 -1 -1 -1 12 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 12 -1 -1 -1 -1 13 -1 -1 -1 -1 -1
-1 -1 0 -1 -1 15 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 19 -1 5 3 -1 -1 -1 -1 -1 -1 -1
-1 12 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 ...

output:

10 17 18.00000000 18.00000000
3 4 50.00000000 50.00000000
28 8 40.00000000 47.00000000
20 23 35.00000000 50.00000000
0 9 27.00000000 47.00000000
10 20 47.00000000 74.00000000
26 3 9.00000000 9.00000000
21 2 29.00000000 29.00000000
1 18 37.00000000 37.00000000
15 26 49.00000000 49.00000000
21 27 36.0...

result:

ok 400 numbers

Test #39:

score: -100
Time Limit Exceeded

input:

30
0 -1 -1 -1 23 58 -1 17 -1 -1 51 -1 21 65 -1 -1 -1 28 -1 45 -1 -1 -1 -1 -1 18 -1 -1 -1 -1
-1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 35 -1 8 -1 -1 48 -1 -1 -1 -1 -1 -1 -1
15 33 0 8 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 35 46 -1 -1 -1 -1 9 -1 -1 -1 -1 14 -1 -1 -1 -1
-1 -1 -1 0 -1 -1 -1 -1 59 67 -1 5...

output:


result: