Submission #51969

#TimeUsernameProblemLanguageResultExecution timeMemory
51969pzdbaDuathlon (APIO18_duathlon)C++14
5 / 100
1076 ms936 KiB
#include <bits/stdc++.h> using namespace std; vector<int> g[55]; bool vis[55]; int ans = 0; bool dfs(int a, int b, int c, int u, int cnt){ vis[u] = 1; if(cnt == 1 && u == b) cnt++; if(cnt == 2 && u == c){ return 1; } for(int i=0;i<g[u].size();i++){ int v = g[u][i]; if(vis[v]) continue; if(dfs(a, b, c, v, cnt)) return 1; } vis[u] = 0; return 0; } int main(){ int n, m; scanf("%d%d", &n, &m); for(int i=0;i<m;i++){ int a, b; scanf("%d%d", &a, &b); g[a].push_back(b); g[b].push_back(a); } for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ for(int k=1;k<=n;k++){ memset(vis, 0, sizeof(vis)); if(i == j || i == k || j == k) continue; ans += dfs(i, j, k, i, 1); } } } printf("%d\n", ans); }

Compilation message (stderr)

count_triplets.cpp: In function 'bool dfs(int, int, int, int, int)':
count_triplets.cpp:12:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<g[u].size();i++){
              ~^~~~~~~~~~~~
count_triplets.cpp: In function 'int main()':
count_triplets.cpp:22:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~
count_triplets.cpp:25:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &a, &b);
   ~~~~~^~~~~~~~~~~~~~~~
#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...