Submission #698732

# Submission time Handle Problem Language Result Execution time Memory
698732 2023-02-14T08:52:21 Z vjudge1 Duathlon (APIO18_duathlon) C++17
10 / 100
1000 ms 10528 KB
#include <bits/stdc++.h>
#include <array>
#define all(v) (v.begin()), (v.end())
#define setall(a, val) for(auto& x : a) x = val
#define ll long long
clock_t start_time;
double get_time() { return (double)(clock() - start_time) / CLOCKS_PER_SEC; }
void init() {
#ifndef ONLINE_JUDGE
	FILE* _ = freopen("in.txt", "r", stdin);
	start_time = clock();
#endif
}
const ll MOD = 998244353;
const ll N = 1e5 + 1;
const ll M = 2e2 + 1;
using namespace std;
//####################################################################################

bool vis[N];
int ans = 0;
vector< vector<int> > v;
void dfs(int cur, int dst) {
	vis[cur] = 1;
	if (dst > 1)
		ans += dst - 1;

	for (int nxt : v[cur]) {
		if (!vis[nxt])
			dfs(nxt, dst + 1);
	}
	vis[cur] = 0;
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); srand(time(0)); //init();

	int n, m;
	cin >> n >> m;
	v.resize(n + 1);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
	}

	for (int i = 1; i <= n; i++) {
		setall(vis, 0);
		dfs(i, 0);
	}
	cout << ans << endl;

	cerr << get_time() << "s" << endl;
}

Compilation message

count_triplets.cpp: In function 'void init()':
count_triplets.cpp:10:8: warning: unused variable '_' [-Wunused-variable]
   10 |  FILE* _ = freopen("in.txt", "r", stdin);
      |        ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1097 ms 10528 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 468 KB Output is correct
2 Correct 15 ms 488 KB Output is correct
3 Correct 15 ms 468 KB Output is correct
4 Correct 22 ms 464 KB Output is correct
5 Correct 20 ms 468 KB Output is correct
6 Correct 20 ms 504 KB Output is correct
7 Correct 23 ms 464 KB Output is correct
8 Correct 20 ms 468 KB Output is correct
9 Correct 19 ms 468 KB Output is correct
10 Correct 14 ms 468 KB Output is correct
11 Correct 13 ms 488 KB Output is correct
12 Correct 9 ms 468 KB Output is correct
13 Correct 6 ms 468 KB Output is correct
14 Correct 3 ms 468 KB Output is correct
15 Correct 3 ms 468 KB Output is correct
16 Correct 3 ms 468 KB Output is correct
17 Correct 9 ms 468 KB Output is correct
18 Correct 9 ms 468 KB Output is correct
19 Correct 9 ms 468 KB Output is correct
20 Correct 9 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1098 ms 5920 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 472 KB Output is correct
2 Correct 17 ms 484 KB Output is correct
3 Incorrect 108 ms 468 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1084 ms 5964 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -