# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
51969 | pzdba | Duathlon (APIO18_duathlon) | C++14 | 1076 ms | 936 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;
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)
# | 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... |