# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
829617 | tolbi | Duathlon (APIO18_duathlon) | C++17 | 1114 ms | 1048576 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma optimize("Bismillahirrahmanirrahim")
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█■█
//█─█─█▄─█▄─█─█─█─█
//Allahuekber
//ahmet23 orz...
//FatihSultanMehmedHan
//YavuzSultanSelimHan
//AbdulhamidHan
//Sani buyuk Osman Pasa Plevneden cikmam diyor
#define author tolbi
#include <bits/stdc++.h>
using namespace std;
#define deci(x) int x;cin>>x;
#define decstr(x) string x;cin>>x;
#define sortarr(x) sort(x.begin(), x.end())
#define sortrarr(x) sort(x.rbegin(), x.rend())
#define rev(x) reverse(x.begin(), x.end())
#define cinarr(x) for (auto &it : x) cin>>it;
#define coutarr(x) for (auto &it : x) cout<<it<<" ";cout<<endl;
#define tol(bi) (1LL<<((int)(bi)))
#define endl '\n'
#define int long long
mt19937 ayahya(chrono::high_resolution_clock().now().time_since_epoch().count());
int32_t main(){
int T = 1;
int tno = 0;
while (T-(tno++)){
deci(n);deci(m);
vector<vector<int>> arr(n);
for (int i = 0; i < m; ++i)
{
deci(u);deci(v);
arr[u-1].push_back(v-1);
arr[v-1].push_back(u-1);
}
vector<int> subsz(n);
int ans = 0;
auto f = [&](int node, int lnode, auto f)->void{
subsz[node]=1;
for (int i = 0; i < arr[node].size(); i++){
if (arr[node][i]==lnode) continue;
f(arr[node][i],node,f);
ans+=subsz[arr[node][i]]*(n-subsz[arr[node][i]]-1);
subsz[node]+=subsz[arr[node][i]];
}
ans+=(subsz[node]-1)*(n-subsz[node]);
};
f(0,-1,f);
cout<<ans<<endl;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |