# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1136115 | Math4Life2020 | 구슬과 끈 (APIO14_beads) | C++20 | 187 ms | 41888 KiB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using pii = pair<ll,ll>;
const ll INF = 1e18;
ll ans = -1;
int main() {
ios_base::sync_with_stdio(false); cin.tie(0);
ll N; cin >> N;
vector<pii> adj[N];
for (ll i=0;i<(N-1);i++) {
ll a,b,c; cin >> a >> b >> c;
a--; b--;
adj[a].push_back({b,c});
adj[b].push_back({a,c});
}
vector<pii> fadj[N];
pii radj[N];
queue<ll> q0;
q0.push(0);
radj[0]={-1,-INF};
vector<ll> itpls;
while (!q0.empty()) {
ll x = q0.front(); q0.pop();
itpls.push_back(x);
for (pii p0: adj[x]) {
if (p0.first!=radj[x].first) {
fadj[x].push_back(p0);
radj[p0.first]={x,p0.second};
# | 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... |