제출 #31605

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
316052017-08-30 02:56:22minkank구슬과 끈 (APIO14_beads)C++14
0 / 100
12 ms2432 KiB
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;
const int N = 1e4 + 5;
int n, dp[N][2], ans;
vector<ii> a[N], b[N];
vector<int> l[N], r[N];
void dfs(int u, int p) {
dp[u][0] = dp[u][1] = 0;
int cnt = 0;
for(int i = 0; i < a[u].size(); ++i) {
int v = a[u][i].first;
if(v == p) continue;
dfs(v, u);
cnt++; b[u][cnt] = a[u][i];
}
l[u][0] = 0;
for(int i = 1; i <= cnt; ++i) {
int v = b[u][i].first, w = b[u][i].second;
l[u][i] = l[u][i - 1] + max(dp[v][1] + w, dp[v][0]);
}
r[u][cnt + 1] = 0;
for(int i = cnt; i >= 1; --i) {
int v = b[u][i].first, w = b[u][i].second;
r[u][i] = r[u][i + 1] + max(dp[v][1] + w, dp[v][0]);
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

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

beads.cpp: In function 'void dfs(int, int)':
beads.cpp:15:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < a[u].size(); ++i) {
                    ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...