QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#102736 | #5663. Tangle: A DAG for storing transactions | WPS# | WA | 1ms | 3684kb | C++17 | 1.2kb | 2023-05-03 16:48:41 | 2023-05-03 16:48:43 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
const int maxn = 1e4+10;
const int mod =(1ll<<31)-1;
const int INF = 0x3f3f3f3f3f3f3f3f;
vector<int>vec[maxn];
int val[maxn];
int sum_val[maxn];
vector<int> vis;
void dfs(int st,int v){
if( vis[st] ) return;
vis[st] = 1;
sum_val[st]+=val[v];
for(auto i:vec[st]){
dfs(i,v);
}
}
void solve(){
int n,th;
cin>>n>>th;
for(int i=1;i<=n;i++){
int now,pe1,pe2,wx;
cin>>now>>pe1>>pe2>>wx;
val[now]=wx;
vec[now].push_back(pe1);
vec[now].push_back(pe2);
}
for(int i=n+1;i>=2;i--){
vis = vector<int>(n+2 , 0);
dfs(i,i);
}
map<int,int>mp;
for(int i=0;i<=n+1;i++){
mp[sum_val[i]]=i;
}
vector<pair<int,int>>as;
for(auto i:mp){
if(i.first>=th){
as.push_back({i.second,i.first});
}
}
sort(as.begin(),as.end());
for(auto i:as){
cout<<i.first<<" "<<i.second<<endl;
}
cout<<as.size();
}
int32_t main(){
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int T=1;
// cin>>T;
while(T--){
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3684kb
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 2
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3584kb
input:
21 20 2 0 1 2 3 1 0 5 4 1 0 2 5 2 1 1 6 1 3 1 7 5 4 1 8 3 7 5 9 2 4 1 10 4 9 1 11 9 4 5 12 4 8 2 13 3 12 2 14 2 10 5 15 11 12 4 16 3 9 2 17 1 16 4 18 0 7 3 19 11 5 2 20 14 4 5 21 19 5 2 22 18 9 4
output:
1 59 2 51 3 25 4 50 5 26 7 21 9 35 7
result:
wrong answer 1st lines differ - expected: '2 51', found: '1 59'