# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
864626 | vnm06 | Duathlon (APIO18_duathlon) | C++14 | 1092 ms | 604 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>
#pragma GCC optimize
#define endl '\n'
using namespace std;
long long n, m, en;
vector<int> gr[55];
long long ans=0;
bitset<55> post;
bitset<55> vzm;
void dfs(int v)
{
if(v==en || vzm[v]==1)
{
vzm|=post;
return;
}
post[v]=1;
int brs=gr[v].size();
for(int i=0; i<brs; i++)
{
int nv=gr[v][i];
if(!post[nv]) dfs(nv);
}
post[v]=0;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n>>m;
for(int i=0; i<m; i++)
{
int v, u;
cin>>v>>u;
gr[v].push_back(u);
gr[u].push_back(v);
}
for(int i=1; i<=n; i++)
{
for(int j=1; j<=n; j++)
{
if(i==j) continue;
vzm.reset();
en=j;
dfs(i);
vzm[i]=0;
vzm[j]=0;
ans+=vzm.count();
vzm.reset();
post.reset();
}
}
cout<<ans<<endl;
return 0;
}
/**
8 7
1 2
2 3
2 4
3 5
5 6
6 7
6 8
4 4
1 2
2 4
2 3
3 4
*/
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... |