# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
55696 | mohammad_kilani | Duathlon (APIO18_duathlon) | C++17 | 1083 ms | 10204 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;
#define mod 1000000007
#define oo 1000000000
const int N = 100010;
int n , m , u , v , needed1, needed2;
vector< int > g[N] ;
int vis[N] ,vis2[N] , vi , vi2;
bool DFS2(int node){
if(vis[node] == vi || vis2[node] == vi2) return false;
if(node == needed2) return true;
vis2[node] = vi2;
for(int i=0;i<g[node].size();i++){
if(DFS2(g[node][i]))
return true;
}
return false;
}
bool DFS(int node){
if(vis[node] == vi) return false;
if(node == needed1){
vi2++;
return DFS2(node);
}
vis[node] = vi;
for(int i=0;i<g[node].size();i++){
if(DFS(g[node][i]))
return true;
}
vis[node] = 0;
return false;
}
int main(){
scanf("%d%d",&n,&m);
for(int i=0;i<m;i++){
scanf("%d%d",&u,&v);
g[u].push_back(v);
g[v].push_back(u);
}
int ans = 0;
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
for(int k=1;k<=n;k++){
if(i == j || i == k || j == k) continue;
needed1 = j;
needed2 = k;
vi++;
if(DFS(i)){
ans++;
}
}
}
}
cout << ans << endl;
return 0;
}
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... |