QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#548995#5663. Tangle: A DAG for storing transactionsskrghariapa#WA 0ms3628kbC++171.1kb2024-09-05 23:05:052024-09-05 23:05:05

Judging History

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

  • [2024-09-05 23:05:05]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3628kb
  • [2024-09-05 23:05:05]
  • 提交

answer

#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
using ll = long long;

vector<vector<int>> gr;
vector<int> w;
vector<int> cw;
vector<bool> visited;

void sebar(int pos, int val){
    if(pos == 0 || pos == 1) return;
    for(auto au : gr[pos]){
        if(!visited[au]){
            visited[au] = true;
            cw[au] += val;
            sebar(au, val);
        }
    }
}

int main(){
    fastio;
    int n, th, x, y, z,wx;
    cin>>n>>th;
    string ans = "";
    gr.resize(n+5);
    w.resize(n+5);
    cw.resize(n+5);
    visited.resize(n+5);
    for(int i = 0; i < n; i++){
        cin>>x>>y>>z>>wx;
        gr[x].push_back(y);
        gr[x].push_back(z);
        w[x] = wx;
        cw[x] = wx;
    }
    for(int i = n+1; i>=2; i--){
        // cout<<i<<" "<<cw[i]<<endl;
        if(cw[i] >= th)
            ans = string()+to_string(i)+" "+to_string(cw[i])+'\n'+ans;
        for(int j = 0; j <= n+1; j++){
            visited[j] = false;
        }
        visited[i] = true;
        sebar(i, w[i]);
    }
    cout<<ans;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3628kb

input:

6 12
2 0 1 3
3 0 2 2
4 1 2 1
5 2 3 3
6 3 4 4
7 3 5 5

output:

2 18
3 14

result:

wrong answer 3rd lines differ - expected: '2', found: ''