답안 #1043283

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1043283 2024-08-04T07:44:55 Z vjudge1 철인 이종 경기 (APIO18_duathlon) C++17
23 / 100
53 ms 22480 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
int const N=2e5+5;
int const mod=1e9+7;

vector<int> adj[N];
vector<int> mem[N];
int sz[N];
bool vis[N];
bool bl=0;
int c=0;
void dfs(int node,int par){
	mem[c].push_back(node);
	vis[node]=1;
	for(int i:adj[node]){
		if(i!=par){
			if(vis[i]){
				bl=1;
				continue;
			}
			dfs(i,node);
			sz[node]+=sz[i];
		}
	}
	sz[node]++;
}

signed main(){
	int n,m;
	cin>>n>>m;
	for (int i = 0; i < m; ++i)
	{
		int u,v;
		cin>>u>>v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	int ans=0;
	for (int i = 1; i <=n; ++i)
		if(vis[i]==0){
			dfs(i,0);
			int cc=sz[i];
			ans+=cc*(cc-1)*(cc-1);
			ans+=cc*cc;
			for(int j:mem[c]){
				ans-=sz[j]*sz[j];
				ans-=(cc-sz[j])*(cc-sz[j]);
			}
			c++;
		}
	if(bl)
		return 0;
	cout<<ans<<endl;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 9764 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 9764 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 53 ms 22480 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 9820 KB Output is correct
2 Correct 3 ms 9820 KB Output is correct
3 Correct 4 ms 10072 KB Output is correct
4 Correct 4 ms 9820 KB Output is correct
5 Correct 3 ms 9820 KB Output is correct
6 Correct 3 ms 9820 KB Output is correct
7 Correct 3 ms 9820 KB Output is correct
8 Correct 3 ms 9820 KB Output is correct
9 Correct 4 ms 9848 KB Output is correct
10 Correct 4 ms 9820 KB Output is correct
11 Correct 3 ms 9820 KB Output is correct
12 Correct 4 ms 9776 KB Output is correct
13 Correct 4 ms 9820 KB Output is correct
14 Correct 3 ms 9820 KB Output is correct
15 Correct 4 ms 9864 KB Output is correct
16 Correct 3 ms 9816 KB Output is correct
17 Correct 4 ms 9820 KB Output is correct
18 Correct 3 ms 9820 KB Output is correct
19 Correct 3 ms 9820 KB Output is correct
20 Correct 3 ms 9916 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 15564 KB Output is correct
2 Correct 40 ms 16372 KB Output is correct
3 Correct 41 ms 16332 KB Output is correct
4 Correct 43 ms 16232 KB Output is correct
5 Correct 41 ms 16328 KB Output is correct
6 Correct 47 ms 19864 KB Output is correct
7 Correct 44 ms 18896 KB Output is correct
8 Correct 44 ms 17964 KB Output is correct
9 Correct 49 ms 17620 KB Output is correct
10 Correct 41 ms 16328 KB Output is correct
11 Correct 45 ms 16332 KB Output is correct
12 Correct 48 ms 16112 KB Output is correct
13 Correct 42 ms 16208 KB Output is correct
14 Correct 38 ms 16208 KB Output is correct
15 Correct 38 ms 15956 KB Output is correct
16 Correct 26 ms 15444 KB Output is correct
17 Correct 36 ms 16848 KB Output is correct
18 Correct 36 ms 16328 KB Output is correct
19 Correct 37 ms 16444 KB Output is correct
20 Correct 37 ms 16324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 9816 KB Output is correct
2 Correct 3 ms 9820 KB Output is correct
3 Incorrect 3 ms 9820 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 15588 KB Output is correct
2 Correct 45 ms 16072 KB Output is correct
3 Incorrect 49 ms 17364 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 9764 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 9764 KB Output isn't correct
2 Halted 0 ms 0 KB -