# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
592118 | Iwanttobreakfree | Fountain (eJOI20_fountain) | C++98 | 717 ms | 49528 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <stack>
using namespace std;
int bin_lift(int a,vector<vector<pair<int,long long>>>& p,int w){
for(int i=17;i>=0;i--){
if(p[a][i].second<w){
w-=p[a][i].second;
a=p[a][i].first;
}
}
//cout<<w<<' ';
return a;
}
void dfs(int a,int par,int w,vector<vector<pair<int,int>>>& g,vector<vector<pair<int,long long>>>& p){
//cout<<a<<' '<<par<<'\n';
p[a][0]={par,w};
for(int i=1;i<18;i++)p[a][i]={p[p[a][i-1].first][i-1].first,p[a][i-1].second+p[p[a][i-1].first][i-1].second};
for(auto x:g[a]){
dfs(x.first,a,x.second,g,p);
}
}
int main(){
int n,q,x,v;
cin>>n>>q;
vector<pair<int,int>> f(n);
vector<vector<pair<int,int>>> g(n+1,vector<pair<int,int>>());
vector<vector<pair<int,long long>>> par(n+1,vector<pair<int,long long>>(18));
for(int i=0;i<n;i++){
cin>>x>>v;
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |