Submission #997633

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
9976332024-06-12 15:15:26fuad27Hard route (IZhO17_road)C++17
100 / 100
324 ms82144 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 500100;
vector<int> g[N];
int n;
pair<int,int> dp[N];
pair<ll,ll> ans={0, 1};
void dfs1(int at, int p) {
dp[at] = {1, 1};
for(int to:g[at]) {
if(to==p)continue;
dfs1(to, at);
if(dp[to].first+1 > dp[at].first) {
dp[at]=dp[to];
dp[at].first++;
}
else if(dp[to].first+1 == dp[at].first) {
dp[at].second+=dp[to].second;
}
}
}
void dfs2(int at, int p) {
sort(g[at].begin(), g[at].end(), [&](int u, int v) {
return dp[u].first > dp[v].first;
});
if(g[at].size()>=3) {
ll a = dp[g[at][0]].first, b = dp[g[at][1]].first, c = dp[g[at][2]].first;
ll res = a*(b+c);
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

road.cpp: In function 'void dfs2(int, int)':
road.cpp:31:18: warning: unused variable 'cntc' [-Wunused-variable]
   31 |     ll cntb = 0, cntc = 0, totcnt=0;
      |                  ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...