Submission #135058

# Submission time Handle Problem Language Result Execution time Memory
135058 2019-07-23T15:08:51 Z Lawliet Duathlon (APIO18_duathlon) C++14
5 / 100
1000 ms 11124 KB
#include <bits/stdc++.h>

#define MAX 100010

using namespace std;
typedef long long int lli;

int n, m;
int n1, n2;

lli ans;

bool can[MAX];
bool marc[MAX];

vector<int> s;

vector<int> grafo[MAX];

void DFS(int i, int t)
{
	if(i == t)
	{
		for(int g = 1 ; g < s.size(); g++)
			can[ s[g] ] = true;

		return;
	}

	marc[i] = true;
	s.push_back( i );

	//printf("i = %d\n",i);

	for(int g = 0 ; g < grafo[i].size() ; g++)
	{
		int prox = grafo[i][g];

		if(marc[prox]) continue;

		//printf("i = %d prox = %d\n",i,prox);

		DFS(prox , t);
	}

	marc[i] = false;
	s.pop_back();
}

int main()
{
	scanf("%d %d",&n,&m);

	for(int g = 0 ; g < m ; g++)
	{
		scanf("%d %d",&n1,&n2);

		grafo[n1].push_back(n2);
		grafo[n2].push_back(n1);
	}

	for(int s = 1 ; s <= n ; s++)
	{
		for(int t = 1 ; t <= n ; t++)
		{
			if(s == t) continue;

			DFS(s , t);

			for(int g = 1 ; g <= n ; g++)
				if(can[g]) ans++;

			memset(can , false , sizeof(can));
		}

		//printf("---- %lld\n",ans);

		//printf("\n\n");
	}

	printf("%lld\n",ans);
}

Compilation message

count_triplets.cpp: In function 'void DFS(int, int)':
count_triplets.cpp:24:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int g = 1 ; g < s.size(); g++)
                   ~~^~~~~~~~~~
count_triplets.cpp:35:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int g = 0 ; g < grafo[i].size() ; g++)
                  ~~^~~~~~~~~~~~~~~~~
count_triplets.cpp: In function 'int main()':
count_triplets.cpp:52:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n,&m);
  ~~~~~^~~~~~~~~~~~~~~
count_triplets.cpp:56:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d",&n1,&n2);
   ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2684 KB Output is correct
2 Correct 4 ms 2808 KB Output is correct
3 Correct 4 ms 2808 KB Output is correct
4 Correct 4 ms 2680 KB Output is correct
5 Correct 4 ms 2808 KB Output is correct
6 Correct 4 ms 2808 KB Output is correct
7 Correct 4 ms 2808 KB Output is correct
8 Correct 6 ms 2808 KB Output is correct
9 Correct 33 ms 2808 KB Output is correct
10 Correct 672 ms 2808 KB Output is correct
11 Correct 4 ms 2808 KB Output is correct
12 Correct 5 ms 2808 KB Output is correct
13 Correct 4 ms 2812 KB Output is correct
14 Correct 5 ms 2808 KB Output is correct
15 Correct 5 ms 2808 KB Output is correct
16 Correct 4 ms 2808 KB Output is correct
17 Correct 5 ms 2808 KB Output is correct
18 Correct 4 ms 2808 KB Output is correct
19 Correct 5 ms 2808 KB Output is correct
20 Correct 4 ms 2808 KB Output is correct
21 Correct 5 ms 2808 KB Output is correct
22 Correct 5 ms 2808 KB Output is correct
23 Correct 4 ms 2808 KB Output is correct
24 Correct 4 ms 2808 KB Output is correct
25 Correct 4 ms 2808 KB Output is correct
26 Correct 5 ms 2808 KB Output is correct
27 Correct 4 ms 2812 KB Output is correct
28 Correct 5 ms 2808 KB Output is correct
29 Correct 4 ms 2808 KB Output is correct
30 Correct 4 ms 2808 KB Output is correct
31 Correct 4 ms 2808 KB Output is correct
32 Correct 4 ms 2808 KB Output is correct
33 Correct 4 ms 2808 KB Output is correct
34 Correct 4 ms 2808 KB Output is correct
35 Correct 5 ms 2808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2684 KB Output is correct
2 Correct 4 ms 2808 KB Output is correct
3 Correct 4 ms 2808 KB Output is correct
4 Correct 4 ms 2680 KB Output is correct
5 Correct 4 ms 2808 KB Output is correct
6 Correct 4 ms 2808 KB Output is correct
7 Correct 4 ms 2808 KB Output is correct
8 Correct 6 ms 2808 KB Output is correct
9 Correct 33 ms 2808 KB Output is correct
10 Correct 672 ms 2808 KB Output is correct
11 Correct 4 ms 2808 KB Output is correct
12 Correct 5 ms 2808 KB Output is correct
13 Correct 4 ms 2812 KB Output is correct
14 Correct 5 ms 2808 KB Output is correct
15 Correct 5 ms 2808 KB Output is correct
16 Correct 4 ms 2808 KB Output is correct
17 Correct 5 ms 2808 KB Output is correct
18 Correct 4 ms 2808 KB Output is correct
19 Correct 5 ms 2808 KB Output is correct
20 Correct 4 ms 2808 KB Output is correct
21 Correct 5 ms 2808 KB Output is correct
22 Correct 5 ms 2808 KB Output is correct
23 Correct 4 ms 2808 KB Output is correct
24 Correct 4 ms 2808 KB Output is correct
25 Correct 4 ms 2808 KB Output is correct
26 Correct 5 ms 2808 KB Output is correct
27 Correct 4 ms 2812 KB Output is correct
28 Correct 5 ms 2808 KB Output is correct
29 Correct 4 ms 2808 KB Output is correct
30 Correct 4 ms 2808 KB Output is correct
31 Correct 4 ms 2808 KB Output is correct
32 Correct 4 ms 2808 KB Output is correct
33 Correct 4 ms 2808 KB Output is correct
34 Correct 4 ms 2808 KB Output is correct
35 Correct 5 ms 2808 KB Output is correct
36 Correct 17 ms 2808 KB Output is correct
37 Correct 17 ms 2808 KB Output is correct
38 Correct 62 ms 2808 KB Output is correct
39 Execution timed out 1072 ms 2720 KB Time limit exceeded
40 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1072 ms 11124 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1068 ms 2808 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1077 ms 6008 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1086 ms 2808 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1063 ms 6008 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2684 KB Output is correct
2 Correct 4 ms 2808 KB Output is correct
3 Correct 4 ms 2808 KB Output is correct
4 Correct 4 ms 2680 KB Output is correct
5 Correct 4 ms 2808 KB Output is correct
6 Correct 4 ms 2808 KB Output is correct
7 Correct 4 ms 2808 KB Output is correct
8 Correct 6 ms 2808 KB Output is correct
9 Correct 33 ms 2808 KB Output is correct
10 Correct 672 ms 2808 KB Output is correct
11 Correct 4 ms 2808 KB Output is correct
12 Correct 5 ms 2808 KB Output is correct
13 Correct 4 ms 2812 KB Output is correct
14 Correct 5 ms 2808 KB Output is correct
15 Correct 5 ms 2808 KB Output is correct
16 Correct 4 ms 2808 KB Output is correct
17 Correct 5 ms 2808 KB Output is correct
18 Correct 4 ms 2808 KB Output is correct
19 Correct 5 ms 2808 KB Output is correct
20 Correct 4 ms 2808 KB Output is correct
21 Correct 5 ms 2808 KB Output is correct
22 Correct 5 ms 2808 KB Output is correct
23 Correct 4 ms 2808 KB Output is correct
24 Correct 4 ms 2808 KB Output is correct
25 Correct 4 ms 2808 KB Output is correct
26 Correct 5 ms 2808 KB Output is correct
27 Correct 4 ms 2812 KB Output is correct
28 Correct 5 ms 2808 KB Output is correct
29 Correct 4 ms 2808 KB Output is correct
30 Correct 4 ms 2808 KB Output is correct
31 Correct 4 ms 2808 KB Output is correct
32 Correct 4 ms 2808 KB Output is correct
33 Correct 4 ms 2808 KB Output is correct
34 Correct 4 ms 2808 KB Output is correct
35 Correct 5 ms 2808 KB Output is correct
36 Correct 17 ms 2808 KB Output is correct
37 Correct 17 ms 2808 KB Output is correct
38 Correct 62 ms 2808 KB Output is correct
39 Execution timed out 1072 ms 2720 KB Time limit exceeded
40 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2684 KB Output is correct
2 Correct 4 ms 2808 KB Output is correct
3 Correct 4 ms 2808 KB Output is correct
4 Correct 4 ms 2680 KB Output is correct
5 Correct 4 ms 2808 KB Output is correct
6 Correct 4 ms 2808 KB Output is correct
7 Correct 4 ms 2808 KB Output is correct
8 Correct 6 ms 2808 KB Output is correct
9 Correct 33 ms 2808 KB Output is correct
10 Correct 672 ms 2808 KB Output is correct
11 Correct 4 ms 2808 KB Output is correct
12 Correct 5 ms 2808 KB Output is correct
13 Correct 4 ms 2812 KB Output is correct
14 Correct 5 ms 2808 KB Output is correct
15 Correct 5 ms 2808 KB Output is correct
16 Correct 4 ms 2808 KB Output is correct
17 Correct 5 ms 2808 KB Output is correct
18 Correct 4 ms 2808 KB Output is correct
19 Correct 5 ms 2808 KB Output is correct
20 Correct 4 ms 2808 KB Output is correct
21 Correct 5 ms 2808 KB Output is correct
22 Correct 5 ms 2808 KB Output is correct
23 Correct 4 ms 2808 KB Output is correct
24 Correct 4 ms 2808 KB Output is correct
25 Correct 4 ms 2808 KB Output is correct
26 Correct 5 ms 2808 KB Output is correct
27 Correct 4 ms 2812 KB Output is correct
28 Correct 5 ms 2808 KB Output is correct
29 Correct 4 ms 2808 KB Output is correct
30 Correct 4 ms 2808 KB Output is correct
31 Correct 4 ms 2808 KB Output is correct
32 Correct 4 ms 2808 KB Output is correct
33 Correct 4 ms 2808 KB Output is correct
34 Correct 4 ms 2808 KB Output is correct
35 Correct 5 ms 2808 KB Output is correct
36 Correct 17 ms 2808 KB Output is correct
37 Correct 17 ms 2808 KB Output is correct
38 Correct 62 ms 2808 KB Output is correct
39 Execution timed out 1072 ms 2720 KB Time limit exceeded
40 Halted 0 ms 0 KB -