QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#357600 | #7936. Eliminate Tree | Whimsical# | WA | 54ms | 14084kb | C++23 | 730b | 2024-03-19 01:38:40 | 2024-03-19 01:38:41 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define F first
#define S second
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main() {
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit);
ll n;cin>>n;
vector<vi> adj(n);
rep(i,0,n-1){
int u,v;cin>>u>>v;u--;v--;
adj[u].pb(v);
adj[v].pb(u);
}
ll c[2]={};
function<void(int,int,int)> dfs = [&](int u, int p, int co){
c[co]++;
for(int v:adj[u]){
if(v==p)continue;
dfs(v,u,co^1);
}
};
dfs(0,-1,0);
ll d=abs(c[1]-c[0]);
cout<<(d+(n+d)/2)<<"\n";
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3812kb
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: 3580kb
input:
4 1 2 2 3 3 4
output:
2
result:
ok 1 number(s): "2"
Test #3:
score: -100
Wrong Answer
time: 54ms
memory: 14084kb
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:
98351
result:
wrong answer 1st numbers differ - expected: '138182', found: '98351'