Submission #398142

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
3981422021-05-03 19:50:07bonopoFactories (JOI14_factories)C++14
100 / 100
5663 ms231436 KiB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define el "\n"
#define f first
#define s second
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
typedef long long ll;
const ll MM=5e5+5, MOD=1e9+7, LOG=20, INF=1e18;
int dep[MM], sz[MM], nxt[MM], in[MM], ot[MM], head[2*MM], ct=1, chn; ll dst[MM], spc[MM];
pair<int,int> st[LOG][4*MM];
bool blk[MM];
struct E {int nxt; pair<int,int> v; } e[2*MM];
void add(int u, int v, int w){
e[chn].v={v,w}; e[chn].nxt=head[u]; head[u]=chn++; }
int lg2(int x) {
return 32-__builtin_clz(x)-1; }
void df1(int u, int pa) {
dep[u]=dep[pa]+1; st[0][ct]={dep[u], u}; in[u]=ct++;
for(int i=head[u]; i!=-1; i=e[i].nxt) {
int v=e[i].v.f, w=e[i].v.s; if(v==pa) continue;
dst[v]=dst[u]+w; df1(v, u); sz[u]+=sz[v];
st[0][ct++]={dep[u], u}; }
ot[u]=ct; }
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...