Submission #300769

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
3007692020-09-17 13:20:13vipghn2003Ball Machine (BOI13_ballmachine)C++14
100 / 100
282 ms32380 KiB
#include<bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
using namespace std;
const int N=1e5+5;
int n,q,mn[N],pos[N],cnt,col[N],p[N][20];
vector<int>adj[N];
void dfs(int u,int par=-1)
{
for(int i=1;i<=18;i++) p[u][i]=p[p[u][i-1]][i-1];
mn[u]=u;
for(auto&v:adj[u])
{
if(v==par) continue;
p[v][0]=u;
dfs(v,u);
mn[u]=min(mn[u],mn[v]);
}
}
void go(int u,int par=-1)
{
vector<pii>order;
for(auto&v:adj[u]) if(v!=par) order.push_back(mp(mn[v],v));
sort(order.begin(),order.end());
for(auto&v:order) go(v.se,u);
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

ballmachine.cpp: In function 'int main()':
ballmachine.cpp:48:7: warning: 'root' may be used uninitialized in this function [-Wmaybe-uninitialized]
   48 |     go(root);
      |     ~~^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...