Submission #1689677


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
using edge = struct {int to;LL cost;};
vector<edge> v[100001];
int depth[100001];

void dfs(int i,int j,LL count){
    auto e=v[i].begin();
    depth[i]=count;
    for(int s=0;s<v[i].size();s++,e++){
        if(e->to==j) continue;
        dfs(e->to,i,count+e->cost);
    }
}

int main(){
    int N;
    cin >> N;
    for(int i=0;i<N-1;i++){
        int x,y;
        LL r;
        cin >> x >> y >> r;
        v[x].push_back({y,r});
        v[y].push_back({x,r});
    }
    int Q,K;
    cin >> Q >> K;
    dfs(K,-1,0);
    for(int i=0;i<Q;i++){
        int x,y;
        cin >> x >> y ;
        cout << depth[x]+depth[y] << endl;
    }
    return 0;
}

Submission Info

Submission Time
Task A - Palindromic Number
User Yukly
Language C++14 (GCC 5.4.1)
Score 0
Code Size 750 Byte
Status RE
Exec Time 105 ms
Memory 2560 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 100
Status
RE × 3
RE × 10
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All sample_01.txt, sample_02.txt, sample_03.txt, subtask_1_1.txt, subtask_1_2.txt, subtask_1_3.txt, subtask_1_4.txt, subtask_1_5.txt, subtask_1_6.txt, subtask_1_7.txt
Case Name Status Exec Time Memory
sample_01.txt RE 99 ms 2560 KB
sample_02.txt RE 98 ms 2560 KB
sample_03.txt RE 98 ms 2560 KB
subtask_1_1.txt RE 99 ms 2560 KB
subtask_1_2.txt RE 98 ms 2560 KB
subtask_1_3.txt RE 98 ms 2560 KB
subtask_1_4.txt RE 99 ms 2560 KB
subtask_1_5.txt RE 105 ms 2560 KB
subtask_1_6.txt RE 99 ms 2560 KB
subtask_1_7.txt RE 98 ms 2560 KB