제출 #126328

#제출 시각아이디문제언어결과실행 시간메모리
126328songc경주 (Race) (IOI11_race)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<LL, int> pii; int N, K, ans; vector<pii> L[202020]; LL S[202020]; int C[202020]; set<pii>* f(int u, int p){ set<pii> *M = new set<pii>, *T; for (pii it : L[u]){ if (it.second == p) continue; T = f(it.second, u); T->insert(pii(-S[it.second], -C[it.second])); S[it.second] += it.first; C[it.second]++; auto P = T->lower_bound(pii(K-S[it.second], -N)); if (P->first == K-S[it.second] && P != T->end()) ans = min(ans, P->second+C[it.second]); if (M->size() < T->size()) { swap(M, T); swap(S[u], S[it.second]); swap(C[u], C[it.second]); } for (pii v : *T) { P = M->lower_bound(pii(K-v.first-S[it.second]-S[u], -N)); if (P->first == K-v.first-S[it.second]-S[u] && P != M->end()) ans = min(ans, P->second+v.second+C[u]+C[it.second]); } for (pii v : *T) M->insert(pii(v.first+S[it.second]-S[u], v.second+C[it.second]-C[u])); T->clear(); } return M; } int main(){ int u, v, w; scanf("%d %d", &N, &K); for (int i=1; i<N; i++){ scanf("%d %d %d", &u, &v, &w); L[u].push_back(pii(w, v)); L[v].push_back(pii(w, u)); } ans = N; f(0, -1); if (ans >= N) ans = -1; printf("%d\n", ans); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

race.cpp: In function 'int main()':
race.cpp:38:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &N, &K);
     ~~~~~^~~~~~~~~~~~~~~~~
race.cpp:40:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d %d", &u, &v, &w);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/tmp/cc9sPZnF.o: In function `main':
race.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cc4Cc3ab.o:grader.cpp:(.text.startup+0x0): first defined here
/tmp/cc4Cc3ab.o: In function `main':
grader.cpp:(.text.startup+0x20): undefined reference to `best_path(int, int, int (*) [2], int*)'
collect2: error: ld returned 1 exit status