Submission #1114697

# Submission time Handle Problem Language Result Execution time Memory
1114697 2024-11-19T12:42:27 Z Onur_Ilgaz Duathlon (APIO18_duathlon) C++17
0 / 100
1000 ms 1048576 KB
#include <bits/stdc++.h>
#define fast cin.tie(0)->sync_with_stdio(0);
#define int long long
#define inf ((int)1e18)
using namespace std;
const int N = 100005;
vector <int> adj[N];
int dp[N][4];

void dfs(int node, int ata) {
	// dp[node][0] = 1;
	dp[node][1] = 1;
	for(auto it:adj[node]) {
		if(it == ata) continue;
		dfs(it, node);
		dp[node][3] += dp[it][3] + dp[it][2];
		dp[node][2] += dp[it][2] + dp[it][1];
		dp[node][1] += dp[it][1] + dp[it][0];
	}
	// cout << node << ": " << dp[node][1] << dp[node][2] << dp[node][3] << '\n';
}

int32_t main(){
	fast
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	dfs(1, 1);
	cout << dp[1][3] * 2;
}
# Verdict Execution time Memory Grader output
1 Runtime error 925 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 925 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1097 ms 675164 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 3664 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 31 ms 10056 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 3664 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 10824 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 925 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 925 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -