Submission #980784

#TimeUsernameProblemLanguageResultExecution timeMemory
980784UnforgettableplDuathlon (APIO18_duathlon)C++17
10 / 100
1106 ms1048576 KiB
#include <bits/stdc++.h> using namespace std; #define int long long vector<int> adj[200001]; int ans; void dfs(int x,int p,int depth){ ans+=depth; for(int&i:adj[x])if(i!=p)dfs(i,x,depth+1); } int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int n,m; cin >> n >> m; for(int i=1;i<=m;i++){ int a,b;cin>>a>>b; adj[a].emplace_back(b); adj[b].emplace_back(a); } for(int i=1;i<=n;i++)dfs(i,0,-1); cout << ans+n << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...