Submission #92499

# Submission time Handle Problem Language Result Execution time Memory
92499 2019-01-03T06:22:15 Z antimirage Duathlon (APIO18_duathlon) C++14
0 / 100
62 ms 12408 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;
	}
	if (fl){
		assert(0);
		for (int i = 1; i <= n; i++)
		{
			if (u[i]) continue;
			cn = 0;
			dfs(i);
			ans += cn * 1ll * (cn - 1) * (cn - 2);
		}
		cout << ans << endl;
	}
	else{
		for (int i = 1; i <= n; i++)
		{
			if (u[i]) continue;
			cn = 0;
			dfs(i);
			ans += cn * 1ll * (cn - 1) * (cn - 2) / 3;
		}
		cout << ans << 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]++;
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 62 ms 12300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 50 ms 12408 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 54 ms 12408 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -