# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
742014 | irmuun | Ball Machine (BOI13_ballmachine) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
/*
struct segtree{
int n;
vector<int>d;
segtree(int x){
n=x;
d.resize(4*n);
build(1,0,n-1);
}
void build(int node,int l,int r){
if(l==r){
d[node]=0;
return;
}
int mid=(l+r)/2;
build(node*2,l,mid);
build(node*2+1,mid+1,r);
d[node]=d[node*2]+d[node*2+1];
}
int query(int node,int l,int r,int L,int R){
if(r<L||R<l||l>r){
return 0;
}
if(l<=L&&R<=r){
return d[node];
}
int mid=(l+r)/2;
return query(node*2,l,mid,L,R)+query(node*2+1,mid+1,r,L,R);
}
void update(int node,int l,int r,int pos,int val){
if(r<pos||pos<l){
return;
}
if(l==r){
d[node]=val;
return;
}
int mid=(l+r)/2;
update(node*2,l,mid,pos,val);
update(node*2+1,mid+1,r,pos,val);
d[node]=d[node*2]+d[node*2+1];
}
};*/
const ll N=1e5+5;
vector<int>v[N],adj[N],mn;
int n,q,root,used[N],mn[N];
set<int>s;
vector<int>ord;
void cal(int v){
mn[v]=v;
for(auto u:adj[v]){
cal(u);
mn[u]=min(mn[u],mn[v]);
}
}
void dfs(int u){
vector<pair<int,int>>p;
for(auto v:adj[u]){
p.pb({mn[v],v});
}
sort(all(p));
for(auto [val,v]:p){
dfs(u);
}
ord.pb(u);
}
void op1(){
int x=*s.begin();
used[x]=1;
}
void op2(){
}
int main(){
cin>>n>>q;
for(int i=1;i<=n;i++){
int p;
cin>>p;
if(p>0){
adj[p-1].pb(i-1);
}
else{
root=i-1;
}
}
while(q--){
int t;
cin>>t;
if(t==1){
int k;
cin>>k;
}
else{
int x;
cin>>x;
x--;
op2(x);
}
}
*/
}