QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#548995 | #5663. Tangle: A DAG for storing transactions | skrghariapa# | WA | 0ms | 3628kb | C++17 | 1.1kb | 2024-09-05 23:05:05 | 2024-09-05 23:05:05 |
Judging History
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;
}
详细
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: ''