Submission #1114697

#TimeUsernameProblemLanguageResultExecution timeMemory
1114697Onur_IlgazDuathlon (APIO18_duathlon)C++17
0 / 100
1097 ms1048576 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...