Submission #59314

# Submission time Handle Problem Language Result Execution time Memory
59314 2018-07-21T13:43:03 Z MatheusLealV Duathlon (APIO18_duathlon) C++17
8 / 100
152 ms 11932 KB
#include <bits/stdc++.h>
#define N 100050
using namespace std;
typedef long long ll;
ll n, m, c, ans, ok[N];
   
vector<ll> grafo[N];
 
ll sz[N], tot = 0, ciclo;

ll ultimo;
  
void dfs(ll x)
{
    ultimo = x;

	tot ++;

	ok[x] = 1;

    if(grafo[x].size() <= 1) ciclo = 0;

	for(auto v: grafo[x])
	{
		if(ok[v]) continue;

		dfs(v);
	}
}
  
int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
  
    cin>>n>>m;    
  
    for(ll i = 1, a, b; i <= m; i++)
    {
        cin>>a>>b;
   
        grafo[a].push_back(b);
  
        grafo[b].push_back(a);
    }

    for(int i = 1; i <= n; i++)
    {
    	if(ok[i]) continue;

    	tot = 0LL;

        ciclo = 1;

    	dfs(i);

       // cout<<i<<" "<<tot<<" "<<ciclo<<" "<<ans<<"\n";

    	if(tot > 2 and ciclo) ans += (tot * (tot - 1) * (tot - 2));

        else if(tot > 2 and !ciclo) ans += (tot * (tot - 1) * (tot - 2))/3;
    }

    cout<<ans<<"\n";
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2680 KB Output is correct
2 Correct 4 ms 2792 KB Output is correct
3 Correct 5 ms 2792 KB Output is correct
4 Correct 5 ms 2920 KB Output is correct
5 Correct 4 ms 2920 KB Output is correct
6 Correct 4 ms 3028 KB Output is correct
7 Incorrect 5 ms 3028 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2680 KB Output is correct
2 Correct 4 ms 2792 KB Output is correct
3 Correct 5 ms 2792 KB Output is correct
4 Correct 5 ms 2920 KB Output is correct
5 Correct 4 ms 2920 KB Output is correct
6 Correct 4 ms 3028 KB Output is correct
7 Incorrect 5 ms 3028 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 122 ms 9976 KB Output is correct
2 Correct 113 ms 9976 KB Output is correct
3 Correct 123 ms 9976 KB Output is correct
4 Correct 131 ms 9976 KB Output is correct
5 Correct 146 ms 9976 KB Output is correct
6 Correct 152 ms 9976 KB Output is correct
7 Correct 88 ms 9976 KB Output is correct
8 Correct 115 ms 9976 KB Output is correct
9 Correct 111 ms 9976 KB Output is correct
10 Correct 94 ms 9976 KB Output is correct
11 Correct 69 ms 9976 KB Output is correct
12 Correct 64 ms 9976 KB Output is correct
13 Correct 60 ms 9976 KB Output is correct
14 Correct 80 ms 9976 KB Output is correct
15 Correct 72 ms 10076 KB Output is correct
16 Correct 61 ms 10516 KB Output is correct
17 Correct 6 ms 10516 KB Output is correct
18 Correct 8 ms 10516 KB Output is correct
19 Correct 7 ms 10516 KB Output is correct
20 Correct 7 ms 10516 KB Output is correct
21 Correct 6 ms 10516 KB Output is correct
22 Correct 6 ms 10516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 10516 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 98 ms 11932 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 11932 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 98 ms 11932 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2680 KB Output is correct
2 Correct 4 ms 2792 KB Output is correct
3 Correct 5 ms 2792 KB Output is correct
4 Correct 5 ms 2920 KB Output is correct
5 Correct 4 ms 2920 KB Output is correct
6 Correct 4 ms 3028 KB Output is correct
7 Incorrect 5 ms 3028 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2680 KB Output is correct
2 Correct 4 ms 2792 KB Output is correct
3 Correct 5 ms 2792 KB Output is correct
4 Correct 5 ms 2920 KB Output is correct
5 Correct 4 ms 2920 KB Output is correct
6 Correct 4 ms 3028 KB Output is correct
7 Incorrect 5 ms 3028 KB Output isn't correct
8 Halted 0 ms 0 KB -