Submission #203731

# Submission time Handle Problem Language Result Execution time Memory
203731 2020-02-22T02:00:08 Z Segtree Duathlon (APIO18_duathlon) C++14
23 / 100
168 ms 13944 KB
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define N 100010
ll n,m;
vector<ll> g[N];
bool vis[N];
ll res,vcnt;
ll dp1[N],dp2[N];
void dfs(ll x){
	vis[x]=1; vcnt++;
	ll v1=1,v2=0;
	for(auto y:g[x])if(vis[y]==0){
		dfs(y);
		res+=v1*dp2[y]+v2*dp1[y];
		v1+=dp1[y],v2+=dp2[y];
	}
	dp1[x]=v1;
	dp2[x]=v2+v1;
}
int main(){
	ll n,m; cin>>n>>m;
	rep(i,m){
		ll a,b; cin>>a>>b;
		a--,b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	ll ans=0;
	rep(i,n)vis[i]=0;
	rep(i,n){
		if(vis[i]==0){
			res=vcnt=0;
			dfs(i);
			res-=vcnt*(vcnt-1)/2;
			res*=2;
			if(res>0)ans+=res;
		}
	}
	cout<<ans<<endl;
}
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 2680 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 2680 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 151 ms 13944 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 2680 KB Output is correct
2 Correct 7 ms 2808 KB Output is correct
3 Correct 7 ms 2808 KB Output is correct
4 Correct 8 ms 2812 KB Output is correct
5 Correct 7 ms 2680 KB Output is correct
6 Correct 7 ms 2680 KB Output is correct
7 Correct 7 ms 2680 KB Output is correct
8 Correct 7 ms 2680 KB Output is correct
9 Correct 7 ms 2808 KB Output is correct
10 Correct 7 ms 2808 KB Output is correct
11 Correct 7 ms 2680 KB Output is correct
12 Correct 7 ms 2680 KB Output is correct
13 Correct 7 ms 2680 KB Output is correct
14 Correct 7 ms 2680 KB Output is correct
15 Correct 7 ms 2680 KB Output is correct
16 Correct 7 ms 2680 KB Output is correct
17 Correct 7 ms 2680 KB Output is correct
18 Correct 7 ms 2680 KB Output is correct
19 Correct 7 ms 2680 KB Output is correct
20 Correct 7 ms 2680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 135 ms 8060 KB Output is correct
2 Correct 133 ms 8060 KB Output is correct
3 Correct 130 ms 8056 KB Output is correct
4 Correct 149 ms 8272 KB Output is correct
5 Correct 131 ms 8056 KB Output is correct
6 Correct 141 ms 10872 KB Output is correct
7 Correct 144 ms 10232 KB Output is correct
8 Correct 153 ms 9848 KB Output is correct
9 Correct 137 ms 9148 KB Output is correct
10 Correct 131 ms 8056 KB Output is correct
11 Correct 131 ms 9336 KB Output is correct
12 Correct 142 ms 9348 KB Output is correct
13 Correct 132 ms 9336 KB Output is correct
14 Correct 120 ms 9024 KB Output is correct
15 Correct 106 ms 8568 KB Output is correct
16 Correct 73 ms 7416 KB Output is correct
17 Correct 114 ms 9576 KB Output is correct
18 Correct 113 ms 9444 KB Output is correct
19 Correct 115 ms 9444 KB Output is correct
20 Correct 116 ms 9576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 2680 KB Output is correct
2 Correct 7 ms 2680 KB Output is correct
3 Incorrect 7 ms 2808 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 137 ms 8056 KB Output is correct
2 Correct 135 ms 7908 KB Output is correct
3 Incorrect 168 ms 8452 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 2680 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 2680 KB Output isn't correct
2 Halted 0 ms 0 KB -