답안 #92495

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
92495 2019-01-03T06:18:00 Z antimirage 철인 이종 경기 (APIO18_duathlon) C++14
0 / 100
72 ms 17528 KB
#include <bits/stdc++.h>
 
#define fr first
#define sc second
#define mk make_pair
#define pb emplace_back
#define all(s) s.begin(), s.end()
 
using namespace std;

const int N = 1e5 + 5;

int n, m, deg[N], x, y, u[N], cn;

vector < vector <int> > g;

long long ans;

bool fl;

void dfs (int v)
{
	cn++;
	u[v] = 1;
	for (auto to : g[v])
	{
		if (u[to]) continue;
		dfs(to);
	}
}

main() 
{
	cin >> n >> m;
	g.resize(n + 1);
	
	for (int i = 1; i <= m; i++)
	{
		scanf("%d%d", &x, &y), deg[x]++, deg[y]++;
		g[x].pb(y);
		g[y].pb(x);
	}	
	for (int i = 1; i <= n; i++)
	{
		if (deg[i] > 1)
			fl = 1;
	}
	dfs(1);
	assert(cn == n);
	if (fl){
		cout << n * 1ll * (n - 1) * (n - 2) << endl;
	}
	else{
		cout << n * 1ll * (n - 1) * (n - 2) / 3 << endl;
	}
}

Compilation message

count_triplets.cpp:32:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() 
      ^
count_triplets.cpp: In function 'int main()':
count_triplets.cpp:39:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &x, &y), deg[x]++, deg[y]++;
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 72 ms 10968 KB Output is correct
2 Correct 55 ms 11000 KB Output is correct
3 Runtime error 66 ms 17528 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 55 ms 7928 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 67 ms 8004 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -