Submission #31619

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
316192017-08-30 03:38:32minkankBeads and wires (APIO14_beads)C++14
0 / 100
4 ms2176 KiB
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;
const int N = 1e4 + 5;
int n, dp[N][2], ans, g[N][2], cnt[N];
vector<ii> a[N], b[N];
vector<int> l[N], r[N], sax[2][N], cax[2][N];
void dfs(int u, int p) {
dp[u][0] = dp[u][1] = 0;
cnt[u] = 0;
for(int i = 0; i < a[u].size(); ++i) {
int v = a[u][i].first;
if(v == p) continue;
dfs(v, u);
cnt[u]++; b[u][cnt[u]] = a[u][i];
}
l[u][0] = 0;
for(int i = 1; i <= cnt[u]; ++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[u] + 1] = 0;
for(int i = cnt[u]; 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

Compilation message (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) {
                    ~~^~~~~~~~~~~~~
beads.cpp: In function 'void redfs(int, int)':
beads.cpp:50:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < a[u].size(); ++i) if(a[u][i].first == p) W = a[u][i].second;
                    ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...