# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
104347 | tc_abd | Duathlon (APIO18_duathlon) | C++14 | 1057 ms | 540 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.
#include <bits/stdc++.h>
using namespace std;
int n,m,ans;
bool done[1009];
vector < int > v[1009];
void dfs(int node,int f,int w){
if(node == f){ans+=w-1;return;}
done[node] = 1;
for(int i=0;i<v[node].size();i++){
int u = v[node][i];
if(!done[u]) dfs(u,f,w+1);
}
}
int main(){
cin>>n>>m;
for(int i=0;i<m;i++){
int a,b;
cin>>a>>b;
a--;b--;
v[a].push_back(b);
v[b].push_back(a);
}
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
memset(done,0,sizeof(done));
dfs(i,j,0);
}
}
cout<<ans*2<<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... |