QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#135478#4433. Kitten and RoombaSommohito#WA 1456ms197328kbC++201.6kb2023-08-05 16:02:322023-08-05 16:02:32

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-05 16:02:32]
  • 评测
  • 测评结果:WA
  • 用时:1456ms
  • 内存:197328kb
  • [2023-08-05 16:02:32]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#ifdef APURBA
#include "DEBUG_TEMPLATE.h"
#else
#define HERE
#define debug(args...)
#endif
#define ALL(x) x.begin(),x.end()
const int M=5e6+5,N=1e6+5;

int n;
vector<int>e[N];
bool vis[M];
int m;
vector<int>all;
ld dp[M];
vector<int>pos[N];

ld run(int idx)
{
    if(idx>=5000)
        return 0;
    if(vis[idx]==1)
        return dp[idx];

    int node=all[idx];

    vis[idx]=1;
    ld sum=0;
    for(int u:e[node])
    {
        auto itr=lower_bound(pos[u].begin(),pos[u].end(),idx);
        if(itr!=pos[u].end())
        {
            sum+=(1+run(*itr));
        }
    }
    sum/=(int)e[node].size();
    return dp[idx]=sum;
}

void TEST_CASES()
{
    int c;
    cin>>n>>c;
    for(int i=1;i<=n;i++)
        pos[i].clear(),e[i].clear();

    for(int i=0;i<n-1;i++)
    {
        int u,v;
        cin>>u>>v;
        e[u].push_back(v);
        e[v].push_back(u);
    }



    cin>>m;
    all.resize(m);
    for(int i=0;i<m;i++)
    {
        vis[i]=0;
        cin>>all[i];
        pos[all[i]].push_back(i);
    }

    if(pos[c].size()==0)
    {
        cout<<0<<"\n";
    }
    else {
        cout<<fixed<<setprecision(10)<<1+run(pos[c][0])<<"\n";
    }


}


/*
*/

int32_t main()
{
#ifndef APURBA
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
    //freopen("input.txt","r",stdin);
    //freopen("out1.txt","w",stdout);
    int t=1;
    cin>>t;
    while(t--)
    {
        TEST_CASES();
    }
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 1456ms
memory: 197328kb

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:

2.7504558565
2.7481610709

result:

wrong answer 1st numbers differ - expected: '5.60942', found: '2.75046', error = '0.50967'