# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
105729 | Pro_ktmr | Fireworks (APIO16_fireworks) | C++14 | 20 ms | 14464 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 LL long long
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define PB push_back
#define MP make_pair
#define MOD 1000000007
int N, M;
vector<pair<int, LL>> edge[300001];
int par[300001];
vector<pair<LL,int>> chi[300001];
void dfs(int now, int p){
for(int i=0; i<edge[now].size(); i++){
if(edge[now][i].first == p) continue;
chi[now].PB(MP(edge[now][i].second, edge[now][i].first));
par[edge[now][i].first] = now;
dfs(edge[now][i].first, now);
}
sort(chi[now].begin(), chi[now].end());
}
int main(){
scanf("%d%d", &N, &M);
for(int i=0; i<N+M; i++){
int P;
LL C;
C--;
scanf("%d%lld", &P, &C);
edge[i].PB(MP(P, C));
edge[P].PB(MP(i, C));
}
par[0] = -1;
dfs(0, -1);
cout << 0 << endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |