QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#54929#4433. Kitten and RoombaMaksiuMocnyJestRE 0ms0kbC++1.0kb2022-10-11 17:41:552022-10-11 17:41:58

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-11 17:41:58]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2022-10-11 17:41:55]
  • 提交

answer

#include<iostream>
#include<vector>

using namespace std;

vector<int>parent ;
typedef pair<long double,long double>pi;

void DFS(int v, int ojciec, vector<vector<int>>&V)
{
    parent[v]=ojciec ;
    for(auto i:V[v])
    {
        if(i==ojciec) continue ;
        DFS(i,v,V) ;
    }
    return ;
}

int main()
{
    int n,c; cin >> n >> c;
    parent.resize(n,n) ;
    vector<vector<int>>V(n,vector<int>()) ;
    for(int i=0;i<n-1;i++)
    {
        int a,b; cin >> a >> b;
        a--,b-- ;
        V[a].push_back(b) ;
        V[b].push_back(a) ;
    }

    DFS(0,n,V) ;

    long double odp=0 ;
    vector<pi>T(n+1,{0,0}) ;
    T[--c]={1,0} ;
    int m; cin >> m;
    while(m--)
    {
        int v; cin >> v;
        v-- ;
        //cout << v+1 << endl ;
        long double idk=T[v].first+T[parent[v]].second ;
        odp+=idk ;
        idk/=V[v].size() ;
        T[v].second+=idk ;
        T[parent[v]].first+=idk ;
        T[v].first=-T[parent[v]].second ;
    }
    cout << odp ;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

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:


result: