Submission #3446303


Source Code Expand

#include<bits/stdc++.h>
#define ui unsigned int
#define ll long long
#define db double
#define ld long double
#define ull unsigned long long
#define mp(a,b) std::make_pair(a,b)
#define ITR(a,b) for(auto a:b)
#define REP(a,b,c) for(register int a=(b),a##end=(c);a<=a##end;++a)
#define DEP(a,b,c) for(register int a=(b),a##end=(c);a>=a##end;--a)
const int MAXN=100+10,MAXM=MAXN*MAXN;
const ld eps=1e-6,inf=1000000000.00;
int n,m,H,e,beg[MAXN],nex[MAXM],to[MAXM],val[MAXN],Mx[MAXN],d[MAXN];
ld f[MAXN][MAXN];
template<typename T> inline void read(T &x)
{
	T data=0,w=1;
	char ch=0;
	while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
	if(ch=='-')w=-1,ch=getchar();
	while(ch>='0'&&ch<='9')data=((T)data<<3)+((T)data<<1)+(ch^'0'),ch=getchar();
	x=data*w;
}
template<typename T> inline void write(T x,char ch='\0')
{
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);
	putchar(x%10+'0');
	if(ch!='\0')putchar(ch);
}
template<typename T> inline void chkmin(T &x,T y){x=(y<x?y:x);}
template<typename T> inline void chkmax(T &x,T y){x=(y>x?y:x);}
template<typename T> inline T min(T x,T y){return x<y?x:y;}
template<typename T> inline T max(T x,T y){return x>y?x:y;}
inline void insert(int x,int y)
{
	to[++e]=y;
	nex[e]=beg[x];
	beg[x]=e;
}
inline ld check(ld base)
{
	REP(i,1,n)REP(j,1,H)f[i][j]=inf;
	REP(i,1,H)f[n][i]=0;
	DEP(x,n-1,1)REP(h,1,H)
		if(Mx[x]<h)
		{
			ld res=0.0;
			for(register int i=beg[x];i;i=nex[i])
				res+=min(f[to[i]][h-val[to[i]]],base+H-(h-val[to[i]]));
			f[x][h]=(1.0/(ld)d[x])*res+1.0;
		}
	return f[1][H];
}
int main()
{
	read(n);read(m);read(H);
	REP(i,1,m)
	{
		int u,v;read(u);read(v);
		insert(u,v);
	}
	REP(i,1,n)read(val[i]);
	REP(x,1,n)for(register int i=beg[x];i;i=nex[i])chkmax(Mx[x],val[to[i]]),d[x]++;
	ld l=0,r=2000000.00,ans=2000000.00;
	while(r-l>eps)
	{
		ld mid=(l+r)*0.5;
		if(check(mid)<=mid)ans=mid,r=mid;
		else l=mid;
	}
	if(ans>1000000)ans=-1;
	printf("%.12Lf\n",ans);
	return 0;
}

Submission Info

Submission Time
Task D - 軍艦ゲーム
User hyj542682306
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1996 Byte
Status AC
Exec Time 76 ms
Memory 512 KB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 77
Set Name Test Cases
All 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 00_sample_04.txt, handmade_01.txt, handmade_02.txt, handmade_03.txt, handmade_04.txt, handmade_05.txt, handmade_06.txt, handmade_07.txt, handmade_08.txt, handmade_09.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt, test_31.txt, test_32.txt, test_33.txt, test_34.txt, test_35.txt, test_36.txt, test_37.txt, test_38.txt, test_39.txt, test_40.txt, test_41.txt, test_42.txt, test_43.txt, test_44.txt, test_45.txt, test_46.txt, test_47.txt, test_48.txt, test_49.txt, test_50.txt, test_51.txt, test_52.txt, test_53.txt, test_54.txt, test_55.txt, test_56.txt, test_57.txt, test_58.txt, test_59.txt, test_60.txt, test_61.txt, test_62.txt, test_63.txt, test_64.txt
Case Name Status Exec Time Memory
00_sample_01.txt AC 1 ms 256 KB
00_sample_02.txt AC 1 ms 256 KB
00_sample_03.txt AC 1 ms 256 KB
00_sample_04.txt AC 1 ms 256 KB
handmade_01.txt AC 1 ms 256 KB
handmade_02.txt AC 1 ms 256 KB
handmade_03.txt AC 1 ms 256 KB
handmade_04.txt AC 1 ms 256 KB
handmade_05.txt AC 1 ms 256 KB
handmade_06.txt AC 1 ms 256 KB
handmade_07.txt AC 1 ms 256 KB
handmade_08.txt AC 4 ms 256 KB
handmade_09.txt AC 1 ms 256 KB
test_01.txt AC 1 ms 256 KB
test_02.txt AC 1 ms 256 KB
test_03.txt AC 5 ms 384 KB
test_04.txt AC 5 ms 384 KB
test_05.txt AC 3 ms 512 KB
test_06.txt AC 8 ms 512 KB
test_07.txt AC 76 ms 512 KB
test_08.txt AC 4 ms 512 KB
test_09.txt AC 3 ms 384 KB
test_10.txt AC 2 ms 256 KB
test_11.txt AC 4 ms 384 KB
test_12.txt AC 1 ms 256 KB
test_13.txt AC 4 ms 384 KB
test_14.txt AC 4 ms 384 KB
test_15.txt AC 2 ms 512 KB
test_16.txt AC 3 ms 512 KB
test_17.txt AC 43 ms 512 KB
test_18.txt AC 39 ms 512 KB
test_19.txt AC 9 ms 384 KB
test_20.txt AC 60 ms 512 KB
test_21.txt AC 4 ms 384 KB
test_22.txt AC 2 ms 384 KB
test_23.txt AC 4 ms 384 KB
test_24.txt AC 6 ms 384 KB
test_25.txt AC 9 ms 384 KB
test_26.txt AC 2 ms 384 KB
test_27.txt AC 4 ms 384 KB
test_28.txt AC 15 ms 384 KB
test_29.txt AC 4 ms 512 KB
test_30.txt AC 5 ms 384 KB
test_31.txt AC 2 ms 256 KB
test_32.txt AC 4 ms 384 KB
test_33.txt AC 48 ms 512 KB
test_34.txt AC 21 ms 384 KB
test_35.txt AC 3 ms 384 KB
test_36.txt AC 48 ms 512 KB
test_37.txt AC 4 ms 512 KB
test_38.txt AC 3 ms 384 KB
test_39.txt AC 3 ms 384 KB
test_40.txt AC 7 ms 384 KB
test_41.txt AC 6 ms 384 KB
test_42.txt AC 5 ms 384 KB
test_43.txt AC 4 ms 384 KB
test_44.txt AC 10 ms 512 KB
test_45.txt AC 4 ms 384 KB
test_46.txt AC 4 ms 384 KB
test_47.txt AC 4 ms 384 KB
test_48.txt AC 4 ms 384 KB
test_49.txt AC 28 ms 384 KB
test_50.txt AC 4 ms 384 KB
test_51.txt AC 7 ms 384 KB
test_52.txt AC 67 ms 512 KB
test_53.txt AC 4 ms 512 KB
test_54.txt AC 15 ms 384 KB
test_55.txt AC 10 ms 384 KB
test_56.txt AC 39 ms 384 KB
test_57.txt AC 8 ms 384 KB
test_58.txt AC 6 ms 384 KB
test_59.txt AC 8 ms 384 KB
test_60.txt AC 8 ms 384 KB
test_61.txt AC 13 ms 384 KB
test_62.txt AC 7 ms 384 KB
test_63.txt AC 1 ms 256 KB
test_64.txt AC 7 ms 512 KB