# INOI 2020 WA Help

I am trying Subtask 1 of this problem Department Strengths | CodeChef.

This is my code

``````#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0);
#define int long long
#define out(x) cout<<x<<"\n"
#define vout(x,n) f(i,1,n+1)cout<<x[i]<<" "
#define rep(i,n) for(int i(0); i<n; i++)
#define f(i,a,b) for(int i(a); i<b; i++)
#define vi vector<int>
#define pb push_back

const int MAXN = 1e5+10;

vi depth(MAXN, -1);

void dfs(int u){
if(depth[v] == -1){
depth[v] = depth[u] + 1;
dfs(v);
}
}
}

int32_t main(){

int t; cin>>t;
while(t--){

int n, m, x, y; cin>>n>>m;

rep(i,m){
cin>>x>>y;
}

//vout(depth,n);

int ans=0; f(i,1,n+1)ans += depth[i];

if(n&1)cout<<"0 "<<ans<<"\n";
else cout<<ans<<" 0\n";

}

return 0;

}
``````

It seems my approach is correct but there is some issue with the implementation.
Can someone tell me when the code fails? Solution: 58574643 | CodeChef

Actually, your approach is the problem, not the implementation.

Your code fails on the sample input, so try looking at the explanation of the sample input and the diagram also.

Hint

The input consists of multiple departments, each of which is a tree. Your code assumes that there is only one tree when there are actually multiple trees.

Actually I figured it out.