답안 #1070958

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1070958 2024-08-22T21:50:05 Z pawned 철인 이종 경기 (APIO18_duathlon) C++17
8 / 100
33 ms 10592 KB
#pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops")

#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;

const char nl = '\n';

void fastIO() {
	ios::sync_with_stdio(false);
	cin.tie(0);
}

const int MAX = 1e5 + 5;

int N, M;

bool vis[MAX];
vi adj[MAX];

vi inc;

void dfs(int n) {
	vis[n] = true;
	inc.pb(n);
	for (int x : adj[n]) {
		if (!vis[x])
			dfs(x);
	}
}

int main() {
	fastIO();
	cin>>N>>M;
	for (int i = 0; i < M; i++) {
		int u, v;
		cin>>u>>v;
		u--; v--;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	ll total = 0;
	for (int i = 0; i < N; i++) {
		if (!vis[i]) {
			inc.clear();
			dfs(i);
			ll K = inc.size();
			ll cnte = 0;
			for (int x : inc)
				cnte += adj[x].size();
			cnte /= 2;
			if (cnte == K - 1)
				total += (K * (K - 1) * (K - 2)) / 3;
			else
				total += (K * (K - 1) * (K - 2));
		}
	}
//	cout<<"ANSWER: ";
	cout<<total<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2720 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Incorrect 1 ms 2652 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2720 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Incorrect 1 ms 2652 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 9172 KB Output is correct
2 Correct 28 ms 10592 KB Output is correct
3 Correct 33 ms 8908 KB Output is correct
4 Correct 28 ms 9688 KB Output is correct
5 Correct 24 ms 8540 KB Output is correct
6 Correct 33 ms 8532 KB Output is correct
7 Correct 25 ms 8028 KB Output is correct
8 Correct 24 ms 8192 KB Output is correct
9 Correct 26 ms 7504 KB Output is correct
10 Correct 24 ms 8012 KB Output is correct
11 Correct 20 ms 7004 KB Output is correct
12 Correct 20 ms 6816 KB Output is correct
13 Correct 20 ms 6776 KB Output is correct
14 Correct 20 ms 6724 KB Output is correct
15 Correct 15 ms 5980 KB Output is correct
16 Correct 15 ms 5980 KB Output is correct
17 Correct 1 ms 2908 KB Output is correct
18 Correct 1 ms 2908 KB Output is correct
19 Correct 2 ms 2908 KB Output is correct
20 Correct 1 ms 2812 KB Output is correct
21 Correct 2 ms 2908 KB Output is correct
22 Correct 1 ms 2908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 22 ms 6608 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 23 ms 6604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2720 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Incorrect 1 ms 2652 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2720 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Incorrect 1 ms 2652 KB Output isn't correct
8 Halted 0 ms 0 KB -