QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#317678 | #7936. Eliminate Tree | one_god_and_two_dogs# | WA | 55ms | 14164kb | C++17 | 628b | 2024-01-29 13:32:46 | 2024-01-29 13:32:46 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
using ll=long long ;
int main(){
cin.tie(0)->sync_with_stdio(0);
int n;
cin>>n;
vector<vector<int>>G(n);
for(int i=1;i<n;++i){
int a,b;
cin>>a>>b;
--a,--b;
G[a].emplace_back(b);
G[b].emplace_back(a);
}
auto dfs=[&](auto self,int x,int fa)->pair<int,int>{
int s1=0,s2=0,c=0;
for(auto y:G[x]){
if(y==fa)continue;
auto [fi,se]=self(self,y,x);
++c;
s2+=se;
s1=min(fi-se,s1);
}
if(c==0)return {0,2};
//cout<<x<<" "<<fa<<" "<<s2<<" "<<s2+s1+1<<endl;
return {s2,s2+s1+1};
};
auto [r1,r2]=dfs(dfs,0,-1);
cout<<r2<<endl;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3576kb
input:
5 1 2 2 3 3 4 3 5
output:
4
result:
ok 1 number(s): "4"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3876kb
input:
4 1 2 2 3 3 4
output:
2
result:
ok 1 number(s): "2"
Test #3:
score: -100
Wrong Answer
time: 55ms
memory: 14164kb
input:
196666 32025 108673 181779 17115 162570 134230 93003 39673 89144 1269 185919 154408 34896 65369 35860 44720 55698 1390 45520 189805 147867 124511 135459 132555 87303 18031 176314 59695 33352 130640 87272 39716 35749 108807 143493 94486 126512 116598 40212 70895 132216 80855 22241 188737 150354 17346...
output:
123456
result:
wrong answer 1st numbers differ - expected: '138182', found: '123456'