Submission #51969

# Submission time Handle Problem Language Result Execution time Memory
51969 2018-06-22T19:07:51 Z pzdba Duathlon (APIO18_duathlon) C++14
5 / 100
1000 ms 936 KB
#include <bits/stdc++.h>
using namespace std;
vector<int> g[55];
bool vis[55];
int ans = 0;
bool dfs(int a, int b, int c, int u, int cnt){
	vis[u] = 1;
	if(cnt == 1 && u == b) cnt++;
	if(cnt == 2 && u == c){
		return 1;
	}
	for(int i=0;i<g[u].size();i++){
		int v = g[u][i];
		if(vis[v]) continue;
		if(dfs(a, b, c, v, cnt)) return 1;
	}
	vis[u] = 0;
	return 0;
}
int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	for(int i=0;i<m;i++){
		int a, b;
		scanf("%d%d", &a, &b);
		g[a].push_back(b);
		g[b].push_back(a);
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			for(int k=1;k<=n;k++){
				memset(vis, 0, sizeof(vis));
				if(i == j || i == k || j == k) continue;
				ans += dfs(i, j, k, i, 1);
			}
		}
	}
	printf("%d\n", ans);
}

Compilation message

count_triplets.cpp: In function 'bool dfs(int, int, int, int, int)':
count_triplets.cpp:12:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<g[u].size();i++){
              ~^~~~~~~~~~~~
count_triplets.cpp: In function 'int main()':
count_triplets.cpp:22: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:25:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &a, &b);
   ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 3 ms 488 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 3 ms 488 KB Output is correct
6 Correct 2 ms 488 KB Output is correct
7 Correct 3 ms 532 KB Output is correct
8 Correct 5 ms 532 KB Output is correct
9 Correct 23 ms 532 KB Output is correct
10 Correct 400 ms 532 KB Output is correct
11 Correct 2 ms 572 KB Output is correct
12 Correct 3 ms 580 KB Output is correct
13 Correct 3 ms 580 KB Output is correct
14 Correct 2 ms 580 KB Output is correct
15 Correct 3 ms 672 KB Output is correct
16 Correct 3 ms 696 KB Output is correct
17 Correct 3 ms 696 KB Output is correct
18 Correct 3 ms 696 KB Output is correct
19 Correct 3 ms 696 KB Output is correct
20 Correct 2 ms 696 KB Output is correct
21 Correct 2 ms 696 KB Output is correct
22 Correct 3 ms 696 KB Output is correct
23 Correct 2 ms 696 KB Output is correct
24 Correct 2 ms 696 KB Output is correct
25 Correct 2 ms 696 KB Output is correct
26 Correct 2 ms 792 KB Output is correct
27 Correct 3 ms 792 KB Output is correct
28 Correct 3 ms 792 KB Output is correct
29 Correct 3 ms 792 KB Output is correct
30 Correct 2 ms 792 KB Output is correct
31 Correct 2 ms 792 KB Output is correct
32 Correct 2 ms 792 KB Output is correct
33 Correct 2 ms 792 KB Output is correct
34 Correct 2 ms 792 KB Output is correct
35 Correct 3 ms 792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 3 ms 488 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 3 ms 488 KB Output is correct
6 Correct 2 ms 488 KB Output is correct
7 Correct 3 ms 532 KB Output is correct
8 Correct 5 ms 532 KB Output is correct
9 Correct 23 ms 532 KB Output is correct
10 Correct 400 ms 532 KB Output is correct
11 Correct 2 ms 572 KB Output is correct
12 Correct 3 ms 580 KB Output is correct
13 Correct 3 ms 580 KB Output is correct
14 Correct 2 ms 580 KB Output is correct
15 Correct 3 ms 672 KB Output is correct
16 Correct 3 ms 696 KB Output is correct
17 Correct 3 ms 696 KB Output is correct
18 Correct 3 ms 696 KB Output is correct
19 Correct 3 ms 696 KB Output is correct
20 Correct 2 ms 696 KB Output is correct
21 Correct 2 ms 696 KB Output is correct
22 Correct 3 ms 696 KB Output is correct
23 Correct 2 ms 696 KB Output is correct
24 Correct 2 ms 696 KB Output is correct
25 Correct 2 ms 696 KB Output is correct
26 Correct 2 ms 792 KB Output is correct
27 Correct 3 ms 792 KB Output is correct
28 Correct 3 ms 792 KB Output is correct
29 Correct 3 ms 792 KB Output is correct
30 Correct 2 ms 792 KB Output is correct
31 Correct 2 ms 792 KB Output is correct
32 Correct 2 ms 792 KB Output is correct
33 Correct 2 ms 792 KB Output is correct
34 Correct 2 ms 792 KB Output is correct
35 Correct 3 ms 792 KB Output is correct
36 Correct 5 ms 792 KB Output is correct
37 Correct 7 ms 792 KB Output is correct
38 Execution timed out 1076 ms 792 KB Time limit exceeded
39 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 856 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 872 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 904 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 904 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 936 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 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 3 ms 488 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 3 ms 488 KB Output is correct
6 Correct 2 ms 488 KB Output is correct
7 Correct 3 ms 532 KB Output is correct
8 Correct 5 ms 532 KB Output is correct
9 Correct 23 ms 532 KB Output is correct
10 Correct 400 ms 532 KB Output is correct
11 Correct 2 ms 572 KB Output is correct
12 Correct 3 ms 580 KB Output is correct
13 Correct 3 ms 580 KB Output is correct
14 Correct 2 ms 580 KB Output is correct
15 Correct 3 ms 672 KB Output is correct
16 Correct 3 ms 696 KB Output is correct
17 Correct 3 ms 696 KB Output is correct
18 Correct 3 ms 696 KB Output is correct
19 Correct 3 ms 696 KB Output is correct
20 Correct 2 ms 696 KB Output is correct
21 Correct 2 ms 696 KB Output is correct
22 Correct 3 ms 696 KB Output is correct
23 Correct 2 ms 696 KB Output is correct
24 Correct 2 ms 696 KB Output is correct
25 Correct 2 ms 696 KB Output is correct
26 Correct 2 ms 792 KB Output is correct
27 Correct 3 ms 792 KB Output is correct
28 Correct 3 ms 792 KB Output is correct
29 Correct 3 ms 792 KB Output is correct
30 Correct 2 ms 792 KB Output is correct
31 Correct 2 ms 792 KB Output is correct
32 Correct 2 ms 792 KB Output is correct
33 Correct 2 ms 792 KB Output is correct
34 Correct 2 ms 792 KB Output is correct
35 Correct 3 ms 792 KB Output is correct
36 Correct 5 ms 792 KB Output is correct
37 Correct 7 ms 792 KB Output is correct
38 Execution timed out 1076 ms 792 KB Time limit exceeded
39 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 3 ms 488 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 3 ms 488 KB Output is correct
6 Correct 2 ms 488 KB Output is correct
7 Correct 3 ms 532 KB Output is correct
8 Correct 5 ms 532 KB Output is correct
9 Correct 23 ms 532 KB Output is correct
10 Correct 400 ms 532 KB Output is correct
11 Correct 2 ms 572 KB Output is correct
12 Correct 3 ms 580 KB Output is correct
13 Correct 3 ms 580 KB Output is correct
14 Correct 2 ms 580 KB Output is correct
15 Correct 3 ms 672 KB Output is correct
16 Correct 3 ms 696 KB Output is correct
17 Correct 3 ms 696 KB Output is correct
18 Correct 3 ms 696 KB Output is correct
19 Correct 3 ms 696 KB Output is correct
20 Correct 2 ms 696 KB Output is correct
21 Correct 2 ms 696 KB Output is correct
22 Correct 3 ms 696 KB Output is correct
23 Correct 2 ms 696 KB Output is correct
24 Correct 2 ms 696 KB Output is correct
25 Correct 2 ms 696 KB Output is correct
26 Correct 2 ms 792 KB Output is correct
27 Correct 3 ms 792 KB Output is correct
28 Correct 3 ms 792 KB Output is correct
29 Correct 3 ms 792 KB Output is correct
30 Correct 2 ms 792 KB Output is correct
31 Correct 2 ms 792 KB Output is correct
32 Correct 2 ms 792 KB Output is correct
33 Correct 2 ms 792 KB Output is correct
34 Correct 2 ms 792 KB Output is correct
35 Correct 3 ms 792 KB Output is correct
36 Correct 5 ms 792 KB Output is correct
37 Correct 7 ms 792 KB Output is correct
38 Execution timed out 1076 ms 792 KB Time limit exceeded
39 Halted 0 ms 0 KB -