# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
744475 |
2023-05-18T15:29:14 Z |
Abito |
Duathlon (APIO18_duathlon) |
C++14 |
|
1000 ms |
37800 KB |
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define endl '\n'
#define ep insert
#define pow pwr
#define sqrt sqrtt
#define elif else if
#define y1 YONE
#define int long long
using namespace std;
const int N=1e6+5;
int n,m,dpar[N],dsz[N],a,b;
vector<int> adj[N];
bool vis[N],dp[N];
int getpar(int x){
if (x==dpar[x]) return x;
return dpar[x]=getpar(dpar[x]);
}
void link(int x,int y){
x=getpar(x);y=getpar(y);
if (x==y) return;
if (dsz[x]>dsz[y]) swap(x,y);
dpar[x]=y;
dsz[y]+=dsz[x];
return;
}
void dfs(int node){
if (node==b) {dp[node]=true;return;}
vis[node]=true;
for (auto u:adj[node]){
if (vis[u]) continue;
dfs(u);
dp[node]|=dp[u];
}return;
}
int32_t main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
cin>>n>>m;
for (int i=1;i<=n;i++){
dsz[i]=1;
dpar[i]=i;
}
for (int i=1;i<=m;i++){
int x,y;
cin>>x>>y;
adj[x].pb(y);
adj[y].pb(x);
link(x,y);
}
int ans=0;
for (int i=1;i<=n;i++){
for (int j=i+1;j<=n;j++){
int x=getpar(i),y=getpar(j);
if (x!=y) continue;
a=i,b=j;
memset(vis,0,sizeof(vis));
memset(dp,0,sizeof(dp));
dfs(a);
for (int i=1;i<=n;i++) ans+=dp[i];
ans-=2;
//cout<<a<<' '<<b<<' '<<ans<<endl;
}
}ans*=2;
cout<<ans<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
13 ms |
25684 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
13 ms |
25684 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1049 ms |
37800 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1069 ms |
25812 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1066 ms |
32032 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1069 ms |
25812 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1069 ms |
32060 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
13 ms |
25684 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
13 ms |
25684 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |