Submission #109299

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
1092992019-05-06 06:13:33PeppaPigBeads and wires (APIO14_beads)C++14
100 / 100
294 ms30952 KiB
#include <bits/stdc++.h>
#define pii pair<int, int>
#define x first
#define y second
using namespace std;
const int N = 2e5+5;
/*
0 - Parent edge any color, No node with 2 blue edges directed to its children
1 - Parent edge must be blue, No node with 2 blue edges directed to its children
2 - Parent edge any color, 1 node in subtree with 2 blue edges directed to its children
3 - Parent edge must be blue, 1 node in subtree with 2 blue edges directed to its children
*/
int n, dp[N][4];
vector<pii> g[N];
void dfs(int u, int p) {
for(pii v : g[u]) if(v.x != p) dfs(v.x, u);
vector<int> V, W, M;
vector<pii> D1, D2;
for(pii v : g[u]) if(v.x != p) {
V.emplace_back(v.x), W.emplace_back(v.y);
M.emplace_back(max(dp[v.x][0], dp[v.x][1] + v.y));
D1.emplace_back(dp[v.x][0] + v.y - M.back(), v.x);
D2.emplace_back(dp[v.x][2] + v.y - M.back(), v.x);
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

beads.cpp: In function 'void dfs(int, int)':
beads.cpp:37:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < M.size(); i++) dp[u][0] += M[i];
                    ~~^~~~~~~~~~
beads.cpp:48:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < M.size(); i++) {
                    ~~^~~~~~~~~~
beads.cpp:54:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < M.size(); i++) 
                    ~~^~~~~~~~~~
beads.cpp: In function 'int main()':
beads.cpp:59:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
beads.cpp:61:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d %d", &a, &b, &c);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...