Submission #104347

#TimeUsernameProblemLanguageResultExecution timeMemory
104347tc_abdDuathlon (APIO18_duathlon)C++14
0 / 100
1057 ms540 KiB
#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)

count_triplets.cpp: In function 'void dfs(int, int, int)':
count_triplets.cpp:9:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<v[node].size();i++){
                 ~^~~~~~~~~~~~~~~
#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...