QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#135502#4433. Kitten and RoombaSommohito#WA 6886ms94640kbC++201.6kb2023-08-05 16:35:592023-08-05 16:36:03

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:36:03]
  • 评测
  • 测评结果:WA
  • 用时:6886ms
  • 内存:94640kb
  • [2023-08-05 16:35:59]
  • 提交

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];
int m;
vector<pair<double,int>>all[N];


void TEST_CASES()
{
    int c;
    cin>>n>>c;
    for(int i=1;i<=n;i++)
        all[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[c].push_back({1,0});
    for(int i=0;i<m;i++)
    {
        int node;
        cin>>node;
        int sz=e[node].size();
        vector<pair<ld,int>>temp;
        for(int j=0;j<all[node].size();j++)
        {
            ld a=all[node][j].first/sz;
            int b=all[node][j].second+1;
            if(a>1e-6&&b<=50)
                temp.push_back({a,b});
        }
//        debug(node,temp,sz);
        for(int u:e[node])
        {
            for(auto v:temp)
            {
                all[u].push_back(v);
            }
        }
        all[node].clear();
    }
    ld sum=0;
    for(int i=1;i<=n;i++)
    {
        for(auto u:all[i])
        {
            sum+=u.first*u.second;
        }
    }
    cout<<fixed<<setprecision(10)<<sum<<"\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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 6886ms
memory: 94640kb

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:

5.4289199554
5.4402291703

result:

wrong answer 1st numbers differ - expected: '5.60942', found: '5.42892', error = '0.03218'