QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#663813#4433. Kitten and RoombaYaeMik0WA 1098ms73736kbC++231.5kb2024-10-21 17:35:072024-10-21 17:35:09

Judging History

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

  • [2024-10-21 17:35:09]
  • 评测
  • 测评结果:WA
  • 用时:1098ms
  • 内存:73736kb
  • [2024-10-21 17:35:07]
  • 提交

answer

#include<bits/stdc++.h>
#define INF 2147483647LL
#define int long long
#define MAXN 5000005
#define mod 1000000007
#define PI 3.14
#define eps 1e-10
#define pa pair<int,int>
#define ms(a,x) memset(a,x,sizeof(a))
#define mc(ar1,ar2) memcpy(ar1,ar2,sizeof(ar2))
#define mkp(a,b) make_pair(a,b)
#define ls (p<<1)
#define rs (p<<1|1)
#define fn(i,st,ed) for(int i=st;i<=ed;++i)
#define fd(i,st,ed) for(int i=st;i>=ed;--i)
#define fg(i,x,head,e) for(int i=head[x];~i;i=e[i].nxt)
using namespace std;
inline int read(){int x=0,f=1;char c=getchar();while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}while(isdigit(c)){x=x*10+c-'0';c=getchar();}return x*f;}
struct edge{int to,nxt;}e[MAXN<<1];
int head[MAXN],ecnt=-1;
inline void insert(int x,int y){e[++ecnt]={y,head[x]};head[x]=ecnt;}
double p[MAXN],lz[MAXN],d[MAXN];
void solve(){
    ecnt=-1;
    int n,c;cin>>n>>c;
    fn(i,0,n)head[i]=-1,p[i]=lz[i]=0;
    p[c]=1;
    fn(i,1,n-1){
        int x,y;cin>>x>>y;
        insert(x,y);insert(y,x);
        d[x]++,d[y]++;
    }
    int m,lst=0;cin>>m;
    double ans=0;
    fn(i,1,m){
        int x;cin>>x;
        //cout<<1<<' '<<x<<' '<<p[x]<<' '<<lz[x]<<endl;
        ans+=p[x]+lz[lst];
        lz[x]+=(p[x]+lz[lst])/d[x];
        p[lst]+=p[x]/d[x];
        p[x]=0;
        lst=x;
        //cout<<2<<' '<<x<<' '<<p[x]<<' '<<lz[x]<<endl;
        //cout<<ans<<endl;
    }
    cout<<setprecision(8)<<ans<<endl;
}
signed main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int T;cin>>T;
    while(T--){solve();}
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 1098ms
memory: 73736kb

input:

2
1000000 315562
969409 917725
324847 719085
524235 603427
576843 433171
75335 238378
266746 487233
80422 95099
594363 96140
858172 261406
958326 466109
233845 350950
863969 345645
689972 81395
395383 27274
93913 208983
523722 380358
108074 172341
130041 692304
737158 383812
752080 33646
154356 6672...

output:

inf
1.6473743e+213

result:

wrong output format Expected double, but "inf" found