답안 #1013954

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1013954 2024-07-04T08:40:28 Z pcc 철인 이종 경기 (APIO18_duathlon) C++17
10 / 100
1000 ms 1048576 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
const int mxn = 1e5+10;
vector<int> tree[mxn];
int N,M;
bitset<mxn> vis;
int dp[mxn];
ll ans = 0;

void dfs1(int now,int fa){
	dp[now] = 1;
	for(auto nxt:tree[now]){
		if(nxt == fa)continue;
		dfs1(nxt,now);
		dp[now] += dp[nxt];
	}
	return;
}
void dfs2(int now,int fa,int sz){
	ll sum = 0;
	for(auto nxt:tree[now]){
		if(nxt == fa)continue;
		ans += sum*dp[nxt]*2;
		sum += dp[nxt];
	}
	ll ts = sz-dp[now];
	ans += sum*ts*2;
	return;
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>N>>M;
	for(int i = 0;i<M;i++){
		int a,b;
		cin>>a>>b;
		tree[a].push_back(b);
		tree[b].push_back(a);
	}
	for(int i = 1;i<=N;i++){
		if(vis[i])continue;
		dfs1(i,i);
		dfs2(i,i,dp[i]);
	}
	cout<<ans<<'\n';
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 561 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 561 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1050 ms 1048576 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 2652 KB Output is correct
2 Correct 7 ms 2860 KB Output is correct
3 Correct 7 ms 2652 KB Output is correct
4 Correct 12 ms 2908 KB Output is correct
5 Correct 11 ms 2908 KB Output is correct
6 Correct 9 ms 2652 KB Output is correct
7 Correct 11 ms 2908 KB Output is correct
8 Correct 11 ms 2904 KB Output is correct
9 Correct 9 ms 2892 KB Output is correct
10 Correct 6 ms 2652 KB Output is correct
11 Correct 6 ms 2648 KB Output is correct
12 Correct 4 ms 2652 KB Output is correct
13 Correct 2 ms 2652 KB Output is correct
14 Correct 2 ms 2652 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 1 ms 2652 KB Output is correct
17 Correct 5 ms 2848 KB Output is correct
18 Correct 5 ms 2652 KB Output is correct
19 Correct 5 ms 2652 KB Output is correct
20 Correct 5 ms 2652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1032 ms 7512 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 2648 KB Output is correct
2 Correct 7 ms 2652 KB Output is correct
3 Runtime error 558 ms 1048576 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1057 ms 7516 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 561 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 561 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -