output stringlengths 52 181k | instruction stringlengths 296 182k |
|---|---|
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200 * 1000 + 10;
const long long INF = 1e15;
long long a[MAXN];
vector<int> adj[MAXN];
long long tot[MAXN], mx[MAXN];
void calc(int x, int par) {
tot[x] = a[x];
mx[x] = -INF;
for (int i = 0; i < ((int)(adj[x]).size()); i++) {
int v = adj[x][i];
... | ### Prompt
Please formulate a CPP solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n priz... |
#include <bits/stdc++.h>
using namespace std;
vector<int> g[200000];
long long int T[200000], sum[200000], maxtree[200000];
long long int ans(int i = 0, int p = -1) {
long long int t = -1e18;
vector<long long int> subtreew;
subtreew.clear();
for (int v : g[i]) {
if (v != p) {
t = max(ans(v, i), t);
... | ### Prompt
Please formulate a CPP solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n priz... |
#include <bits/stdc++.h>
using namespace std;
int vis[200002];
long long a[200002], dp[200002], ans = -1e18;
;
vector<vector<int> > adj(200002);
long long dfs(int v) {
if (vis[v] == 1) {
return dp[v];
}
vis[v] = 1;
long long s = 0;
for (int i = 0; i < adj[v].size(); i++) {
if (vis[adj[v][i]] == 0) {
... | ### Prompt
Please formulate a Cpp solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n priz... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 5;
struct tree {
int v, to;
} p[2 * maxn];
int t[maxn];
int tot;
long long a[maxn];
long long sons[maxn], dp[maxn];
long long ans;
void add(int v, int u) {
p[tot].v = v;
p[tot].to = t[u];
t[u] = tot++;
}
void dfs(int fa, int v) {
sons[v] ... | ### Prompt
Your task is to create a Cpp solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took ... |
#include <bits/stdc++.h>
using namespace std;
vector<vector<long long>> g;
vector<long long> val;
vector<long long> d;
vector<pair<long long, long long>> dp;
vector<long long> dpd;
void dfs(long long v, long long pred) {
long long ans = 0;
for (int i = 0; i < g[v].size(); ++i) {
if (g[v][i] == pred) continue;
... | ### Prompt
Generate a cpp solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n prizes for t... |
#include <bits/stdc++.h>
using namespace std;
long long n, a[200005];
vector<long long> edge[200005];
long long bestOne[200005];
long long cutVal[200005];
bool impossible = true;
long long res = -1e9;
bool seen[200005];
void solve(long long ind, long long parent) {
if (edge[ind].empty()) return;
if (seen[ind]) retu... | ### Prompt
Create a solution in cpp for the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n prizes for... |
#include <bits/stdc++.h>
using namespace std;
const int MaxN = 4e5;
int m, n, all, last[MaxN + 5], pre[MaxN + 5], other[MaxN + 5];
int flag, cnt;
long long f[MaxN + 5], a[MaxN + 5], W, sum1[MaxN + 5], sum2[MaxN + 5];
void Build(int x, int y) {
pre[++all] = last[x];
last[x] = all;
other[all] = y;
}
void Dfs(int x,... | ### Prompt
Your task is to create a CPP solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took ... |
#include <bits/stdc++.h>
using namespace std;
long long n, m, x, y, z, flag = 0;
vector<long long> sum(200005), mx(200005, INT_MIN);
vector<int> adj[200005 + 1];
vector<int> pl(200005 + 1);
map<int, int> vis;
void dfs(int a) {
vis[a] = 1;
for (int i = 0; i < adj[a].size(); i++) {
if (vis[adj[a][i]] == 0) {
... | ### Prompt
Please formulate a Cpp solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n priz... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 200;
vector<int> g[maxn];
long long val[maxn];
long long sum[maxn];
long long ma[maxn];
long long ans = -1e18;
int n, dep;
void dfs0(int u, int fa) {
dep++;
if (dep == n) {
n = -1;
return;
}
for (int i = 0; i < g[u].size(); i++) {
... | ### Prompt
Develop a solution in cpp to the problem described below:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n priz... |
#include <bits/stdc++.h>
using namespace std;
const int N = 200001;
const long long inf = 1e12;
vector<int> adj[N];
long long val[N];
long long t[N];
long long max_d[N];
long long ans = -inf;
void dfs(int u, int parent) {
t[u] += val[u];
for (auto v : adj[u]) {
if (v != parent) {
dfs(v, u);
t[u] += ... | ### Prompt
Construct a Cpp code solution to the problem outlined:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n prizes ... |
#include <bits/stdc++.h>
int n;
long long ans = LLONG_MIN;
long long sum[(200010)], mxx[(200010)];
std::vector<int> mat[(200010)];
void dfs(int u, int fa) {
long long nsum = 0, nmxx = LLONG_MIN;
for (auto v : mat[u]) {
if (v == fa) continue;
dfs(v, u);
if (nmxx != LLONG_MIN) {
ans = std::max(ans, ... | ### Prompt
Please formulate a CPP solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n priz... |
#include <bits/stdc++.h>
using namespace std;
const long long inf = 0x3f3f3f3f3f3f3f3f;
long long dp[200005], val[200005];
const int maxn = 400005;
int tot;
int n;
vector<int> edge[maxn];
long long ans;
void dfs(int u, int fa) {
for (int i = 0; i < edge[u].size(); i++) {
int v = edge[u][i];
if (v == fa) conti... | ### Prompt
Construct a CPP code solution to the problem outlined:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n prizes ... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 200009;
const long long int ninf = -1e17;
int n, dfstime[maxn], until[maxn], weight[maxn];
long long int sumweight[maxn], st[maxn];
vector<vector<int> > g;
void fillsumw(int u, int par, int& curtime) {
sumweight[u] = weight[u];
dfstime[u] = curtime;
+... | ### Prompt
Generate a Cpp solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n prizes for t... |
#include <bits/stdc++.h>
using namespace std;
const int M = 2e5 + 7;
const long long q = 7057594037927903;
const long long prime = 2137;
int n, a, b, odwiedzone[M], wazne;
long long tab[M], rozmiar[M], dp[M], wynik;
vector<int> v[M], synowie[M];
vector<long long> v2;
void wczytaj() {
scanf("%d", &n);
for (int i = 1... | ### Prompt
Please formulate a Cpp solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n priz... |
#include <bits/stdc++.h>
using namespace std;
long long maxv[200001], sumv[200001], a[200001];
vector<int> tree[200001];
pair<long long, long long> ansf = {LONG_MIN / 2, LONG_MIN / 2};
int n, u, v;
bool visited[200001];
void dfs(int v) {
visited[v] = 1;
int c = 0;
long long s = 0;
vector<long long> val;
for (... | ### Prompt
Please formulate a Cpp solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n priz... |
#include <bits/stdc++.h>
using namespace std;
long long int m, i, j, n, tmp, p, q, cnt, d, k, u, vv, t,
ans = -12345678998, a[223456], mx[223456], sm[223456];
string s;
vector<vector<long long int> > g(223456);
void dfs(long long int ver, long long int par) {
mx[ver] = -12345678998;
sm[ver] = a[ver];
for (aut... | ### Prompt
Generate a cpp solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n prizes for t... |
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
struct node {
int v, nxt;
} edge[200010 * 2];
long long dp[200010], sum[200010], w[200010], head[200010], tot, ans;
void add(int u, int v) {
edge[tot].v = v;
edge[tot].nxt = head[u];
head[u] = tot++;
}
void dfs(int u, int fa) {
sum... | ### Prompt
Generate a Cpp solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n prizes for t... |
#include <bits/stdc++.h>
using namespace std;
vector<long long int> a(200001);
vector<long long int> adj[200001];
long long int n, ans;
long long int sum[200001];
long long int sum_dfs(long long int node, long long int par) {
long long int pq = a[node];
for (auto it : adj[node]) {
if (it != par) {
pq += s... | ### Prompt
Create a solution in Cpp for the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n prizes for... |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n;
std::vector<int> adj[N];
long long sub[N];
long long mx[N];
int a[N];
long long ans;
void dfs(int u, int par) {
mx[u] = -100000000000000000LL;
sub[u] = a[u];
for (auto x : adj[u]) {
if (x != par) {
dfs(x, u);
sub[u] += sub... | ### Prompt
Construct a Cpp code solution to the problem outlined:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n prizes ... |
#include <bits/stdc++.h>
using namespace std;
pair<int64_t, int64_t> f[200005];
int n;
int64_t res = -1e15, a[200005], sum[200005];
bool Free[200005];
vector<int> g[200005];
void DFS(int u) {
sum[u] = a[u];
Free[u] = true;
f[u] = pair<int64_t, int64_t>(-1e15, -1e15);
for (int i = 0; i < g[u].size(); i++)
if... | ### Prompt
Your task is to create a CPP solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took ... |
#include <bits/stdc++.h>
using namespace std;
const int MXN = 1e6 + 30;
const int MAXN = 1e3 + 123;
const long long INF = 1e15;
const long long BINF = 1e18;
const int MOD = 1e9 + 7;
const long double EPS = 1e-15;
long long n;
long long a[MXN], cnt;
long long u[MXN];
long long sum[MXN], q;
vector<int> g[MXN];
long long ... | ### Prompt
Your task is to create a CPP solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took ... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 100;
vector<long long> nei[maxn];
bool mark[maxn];
long long sum[maxn];
long long arr[maxn];
long long dp[maxn];
long long n, m;
bool kid = false;
const long long lim = -2e15;
long long ans = -2e15;
void dfs(int v) {
long long max1 = lim, max2 = ... | ### Prompt
Create a solution in Cpp for the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n prizes for... |
#include <bits/stdc++.h>
using namespace std;
vector<int> g[200005];
long long ans;
long long w[200005];
long long s[200005];
long long m[200005];
void dfs(int p, int pp) {
s[p] = w[p];
m[p] = -9223372036854775807ll;
for (int i = 0; i < g[p].size(); i++) {
if (pp == g[p][i]) continue;
dfs(g[p][i], p);
... | ### Prompt
Construct a cpp code solution to the problem outlined:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n prizes ... |
#include <bits/stdc++.h>
using namespace std;
class TreeNode {
public:
long long val;
long long maxiTree;
long long sumTree;
long long maxi_two;
bool exist;
vector<TreeNode*> child;
};
void construct_tree(int x, TreeNode** root, vector<long long>& a,
vector<vector<int> >& g, vector<bool... | ### Prompt
Your task is to create a Cpp solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took ... |
#include <bits/stdc++.h>
using namespace std;
long long P[200001];
long long val[200001];
long long Seg[1 << 20 + 1];
int n, first, second;
vector<vector<int> > V(200001);
vector<vector<long long> > V2(200001);
bool Vis[200001];
int F[200001];
int L[200001];
int History[400002];
long long Ps[400002];
long long Mx[40000... | ### Prompt
Please formulate a cpp solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n priz... |
#include <bits/stdc++.h>
using namespace std;
const long long int INF = -1e17;
long long int ans = INF;
map<long long int, vector<long long int>> edges;
map<long long int, bool> vis;
map<long long int, long long int> p;
pair<long long int, long long int> dfs(long long int node) {
long long int s = p[node];
vector<l... | ### Prompt
Please provide a CPP coded solution to the problem described below:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They t... |
#include <bits/stdc++.h>
using namespace std;
long long inf = -(long long)1e15;
int a[200001];
int n;
vector<int> adj[200001];
long long sum[200001], dp1[200001], dp2[200001];
void dfs(int cur, int prev) {
sum[cur] = a[cur];
for (auto nxt : adj[cur]) {
if (nxt == prev) continue;
dfs(nxt, cur);
sum[cur] ... | ### Prompt
Please provide a cpp coded solution to the problem described below:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They t... |
#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 10;
const long long inf = 2e9 + 10;
const long long INF = 2e18 + 10;
const long long MOD = 1e9 + 7;
long long dp[N], s[N], Sz[N], n, ans = -INF, a[N];
vector<long long> g[N];
void dfs(long long u, long long p = -1) {
Sz[u] = 1;
s[u] = a[u];
f... | ### Prompt
Please formulate a Cpp solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n priz... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> a(n, 0);
for (int i = 0; i < n; i++) cin >> a[i];
vector<int> row;
vector<vector<int>> g(n, row);
vector<vector<int>> tree(n, row);
for (int i = 0; i < n - 1; i++) {
int u, v;
cin >> u >> v;
u--;
v--;... | ### Prompt
Please create a solution in Cpp to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n priz... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
int a[MAXN];
int n, par[MAXN];
vector<int> adj[MAXN];
long long d[MAXN];
long long ans = -1e18;
long long dfs(int u) {
long long mx1 = -1e18, mx2 = -1e18;
d[u] = a[u];
for (int i = 0; i < adj[u].size(); i++) {
int v = adj[u][i];
if (v... | ### Prompt
Generate a Cpp solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n prizes for t... |
#include <bits/stdc++.h>
using namespace std;
int n;
long long a[200010] = {};
vector<int> e[200010];
long long t[200010] = {};
long long q[200010] = {};
int s, b;
long long ans = -222147483600ll;
bool cmp(long long x, long long y) { return x > y; }
void dfs(int x, int y) {
vector<long long> w;
t[x] += a[x];
q[x]... | ### Prompt
Develop a solution in cpp to the problem described below:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n priz... |
#include <bits/stdc++.h>
using namespace std;
const int N = (int)2e5 + 123;
const long long INF = (long long)1e18 + 123;
const int inf = (int)1e9 + 123;
const int MOD = (int)1e9 + 7;
long long val[N], mx[N], a[N];
int n;
vector<int> g[N];
void dfs_calc(int x, int par = -1) {
val[x] += a[x];
for (auto to : g[x]) {
... | ### Prompt
Please create a solution in Cpp to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n priz... |
#include <bits/stdc++.h>
const long long INF = (long long)1e18 + 123;
const long long inf = (long long)1e15 + 123;
const int mod = 1e9 + 7;
using namespace std;
vector<int> g[200011];
bool u[200011];
int n, d[200011];
long long a[200011];
long long sub[200011], mx[200011], ans = -INF;
void dfs(int v = 1, int par = 0) {... | ### Prompt
Create a solution in Cpp for the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n prizes for... |
#include <bits/stdc++.h>
using namespace std;
vector<int> adj[200000];
int n;
vector<int> a;
long long ones[200000];
long long twos[200000];
long long subsum[200000];
long long totans = LLONG_MIN;
void dfs(int no, int last) {
vector<int> chil;
for (int i = 0; i < (int((adj[no]).size())); ++i) {
int to = adj[no]... | ### Prompt
In CPP, your task is to solve the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n prizes fo... |
#include <bits/stdc++.h>
using namespace std;
const int N = (2e5) + 111;
long long vals[N];
long long dp[2][N];
long long sz[N];
vector<int> g[N];
int n;
bool ok = 0;
long long pre(int v, int p) {
long long &ans = sz[v];
ans = vals[v];
for (int to : g[v])
if (to != p) {
ans += pre(to, v);
}
return... | ### Prompt
Your challenge is to write a CPP solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They t... |
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int dx[8] = {1, -1, 0, 0, -1, -1, 1, 1};
int dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};
vector<long long> adj[200010], val(300010, -1), vis(300010, 0), dis(300010, -1);
long long sum[200010], dp[200010];
int myr... | ### Prompt
Please formulate a Cpp solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n priz... |
#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 50;
int a[N];
vector<int> adj[N];
vector<int> child[N];
long long sum[N];
long long mx[N];
long long ans = LLONG_MIN;
void dfs1(int cur, int par) {
long long summ = a[cur];
bool leaf = true;
for (auto nxt : adj[cur]) {
if (nxt == par) {
... | ### Prompt
Generate a cpp solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n prizes for t... |
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e16 + 7;
long long n, ans = -inf;
int a[200001];
long long sum[200001], maxx[200001];
bool vis[200001];
vector<vector<int> > lst;
void dfs(int i) {
long long ans1 = -inf, ans2 = -inf;
vis[i] = 1;
for (int j = 0; j < lst[i].size(); j++) {
if ... | ### Prompt
Generate a CPP solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n prizes for t... |
#include <bits/stdc++.h>
using namespace std;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cer... | ### Prompt
Create a solution in cpp for the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n prizes for... |
#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
inline std::ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& p) {
return os << "(" << p.first << ", " << p.second << ")";
}
template <typename T>
inline std::ostream& operator<<(std::ostream& os, const vector<T>& v) {
bo... | ### Prompt
Please create a solution in CPP to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n priz... |
#include <bits/stdc++.h>
using namespace std;
const int block_size = 320;
const long long mod = 1e9 + 7;
const long double eps = 1e-9;
const int inf = mod;
const long double PI = atan(1) * 4;
template <typename T>
inline int sign(const T &a) {
if (a < 0) return -1;
if (a > 0) return 1;
return 0;
}
template <typen... | ### Prompt
Construct a cpp code solution to the problem outlined:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n prizes ... |
#include <bits/stdc++.h>
using namespace std;
long long a[200000], sm[200000], mx;
vector<unsigned int> tr[200000];
bool v[200000], z;
long long dfs(unsigned int x) {
v[x] = true;
unsigned int sz = tr[x].size(), c = 0;
long long s[2] = {LLONG_MIN / 2 + 1, LLONG_MIN / 2 + 1};
sm[x] = a[x];
for (unsigned int i ... | ### Prompt
Construct a CPP code solution to the problem outlined:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n prizes ... |
#include <bits/stdc++.h>
using namespace std;
vector<int> adj[200001];
int vis[200001];
long long int res, a[200001];
pair<long long int, long long int> dfs(int i) {
vis[i] = 1;
if (adj[i].size() == 1 && i) return make_pair(a[i], a[i]);
int j;
long long int l, r, xsum, ysum;
pair<long long int, long long int>... | ### Prompt
Generate a cpp solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n prizes for t... |
#include <bits/stdc++.h>
using namespace std;
vector<int> v[200005];
long long s[200005], dp[200005], arr[200005];
void dfs(int node, int pnode) {
s[node] = arr[node];
for (int i = 0; i < v[node].size(); i++) {
if (v[node][i] != pnode)
dfs(v[node][i], node), s[node] += s[v[node][i]],
dp[node] = ... | ### Prompt
Create a solution in cpp for the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n prizes for... |
#include <bits/stdc++.h>
using namespace std;
class Node {
public:
int id;
int a;
bool single;
long long sum;
long long m[2] = {0, 0};
Node *f = NULL;
vector<Node *> s;
Node(int id, int a) : id(id), a(a) {}
void dfs() {
for (int i = 0; i < s.size(); ++i) {
if (s[i] == f) {
s[i] = s[... | ### Prompt
Generate a Cpp solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n prizes for t... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const int maxm = 2e5 + 10;
const long long mod = 998244353;
const int inf = 0x3ffffff;
const double eps = 1e-5;
long long a[maxn], res[maxn];
int n;
vector<long long> G[maxn], h[maxn];
long long maxnum = LLONG_MIN;
bool cmp(long long a, long long ... | ### Prompt
Your challenge is to write a CPP solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They t... |
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 200000;
const long long INF = LLONG_MAX / 2LL;
vector<int> G[MAX_N];
int A[MAX_N];
long long T[MAX_N], DP[MAX_N], DP2[MAX_N];
void initGraph(int n) {
for (int i = 0; i < n; i++) G[i].clear();
}
void add(int u, int v) {
G[u].push_back(v);
G[v].push_ba... | ### Prompt
Your challenge is to write a CPP solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They t... |
#include <bits/stdc++.h>
using namespace std;
long long sol[200000];
long long solve(int in, vector<int> v[], int visited[], int a[]) {
if (sol[in] != -2e16) {
return sol[in];
}
long long ans = a[in];
visited[in] = 1;
for (int i = 0; i < v[in].size(); i++) {
if (visited[v[in][i]] == 0) {
ans += ... | ### Prompt
Construct a cpp code solution to the problem outlined:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n prizes ... |
#include <bits/stdc++.h>
const int N = 2e5 + 10;
const int inf = 2 * 0x3f3f3f3f;
using namespace std;
long long num[N], dp[N], ans;
vector<int> vt[N];
void dfs(int u, int f) {
int i;
for (i = 0; i < vt[u].size(); i++) {
int v = vt[u][i];
if (v == f) continue;
dfs(v, u);
num[u] += num[v];
if (dp[... | ### Prompt
Please formulate a CPP solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n priz... |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAX_N = 200002;
const ll INF = -1999999999999;
ll n, m, u, v, ans = INF, ples[MAX_N], visit[MAX_N], pod[MAX_N], max_pod[MAX_N],
dp[MAX_N];
vector<vector<int> > G(MAX_N);
bool compare(const int &a, const int &b) { return max_pod... | ### Prompt
Your challenge is to write a CPP solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They t... |
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e16;
const int N = 2e5 + 10;
int n;
long long a[N], sum[N], mx[N], total = 0, ans = -INF;
vector<int> g[N];
void dfs(int u, int p) {
long long before = total;
vector<long long> childs;
long long mm = -INF;
for (int i = 0; i < ((int)g[u].size()... | ### Prompt
Generate a Cpp solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n prizes for t... |
#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 10;
const long long inf = 1e18;
long long value[N], sumSub[N], subMx[N];
vector<long long> adj[N];
long long res;
void dfs(long long node, long long par) {
long long i = 0;
for (long long to : adj[node]) {
if (to == par) {
adj[node].e... | ### Prompt
Create a solution in CPP for the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n prizes for... |
#include <bits/stdc++.h>
using namespace std;
template <class T1>
T1 GCD(T1 A, T1 B) {
if (B == 0)
return A;
else
return GCD(B, A % B);
}
template <class T2>
T2 mulmod(T2 a, T2 b) {
T2 x = 0, y = a % 1000000007;
while (b) {
if (b % 2 == 1) {
x = (x + y) % 1000000007;
}
y = (2 * y) % 10... | ### Prompt
Construct a CPP code solution to the problem outlined:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n prizes ... |
#include <bits/stdc++.h>
using namespace std;
const int N = 2 * 1e5 + 10;
long long a[N], n;
long long ans = 1e15;
vector<long long> g[N];
long long dp[N];
bool mark[N] = {0};
void dfs1(int u) {
mark[u] = 1;
for (int i = 0; i < g[u].size(); i++) {
if (mark[g[u][i]] == 0) {
dfs1(g[u][i]);
a[u] += a[g... | ### Prompt
Generate a Cpp solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n prizes for t... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 200010;
const long long inf = 2e18;
vector<int> e[maxn];
int a[maxn];
long long b[maxn];
bool vis[maxn];
long long ans = -inf;
long long dfs(int u) {
vis[u] = true;
b[u] = a[u];
priority_queue<long long> q;
long long Max = -inf;
for (int i = 0; i ... | ### Prompt
Develop a solution in Cpp to the problem described below:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n priz... |
#include <bits/stdc++.h>
using namespace std;
long long v[200010];
vector<int> adj[200010];
long long mxs[200010], sumtree[200010];
void dfs(int x, int p) {
sumtree[x] = v[x];
mxs[x] = -1e9;
for (int i : adj[x]) {
if (i != p) {
dfs(i, x);
mxs[x] = max(mxs[i], mxs[x]);
sumtree[x] += sumtree[i... | ### Prompt
Construct a CPP code solution to the problem outlined:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n prizes ... |
#include <bits/stdc++.h>
using namespace std;
const int N = 500000;
const long long minx = -0x5fffffffffffffff;
struct nn {
long long x, y;
nn() { y = minx; }
};
int n, u, v;
nn num[N];
vector<int> node[N];
long long dfs(int f, int x) {
for (int i = 0; i < node[x].size(); i++) {
if (node[x][i] == f) continue;... | ### Prompt
Please create a solution in CPP to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n priz... |
#include <bits/stdc++.h>
using namespace std;
long long tree[4 * 200005];
long long sons[200005];
long long A[200005];
int in[200005], out[200005];
int TIME = 0;
int n;
vector<int> G[200005];
void dfs(int now, int par) {
int size = G[now].size();
TIME++;
in[now] = TIME;
sons[now] = A[now];
for (int i = 0; i <... | ### Prompt
Your task is to create a Cpp solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took ... |
#include <bits/stdc++.h>
using namespace std;
const long long inf = 0x7fffffff;
const long long mod = 1e9 + 7;
const double eps = 1e-8;
const long long linf = 1e18;
const long long MAXN = 2e5 + 10;
const long long MAXM = MAXN << 2;
const double E = 2.718281828;
const double pi = acos(-1.0);
struct node {
int to, next... | ### Prompt
Please provide a Cpp coded solution to the problem described below:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They t... |
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x7fffffff;
const long long INFF = 0x7fffffffffffffff;
const double pi = 3.141592653589793;
const double inf = 1e18;
const double eps = 1e-8;
const long long mod = 1e9 + 7;
struct edges {
int to;
int next;
} edge[1000005];
long long mx = -INFF;
int head[... | ### Prompt
Your challenge is to write a Cpp solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They t... |
#include <bits/stdc++.h>
using namespace std;
vector<int> a[200005];
long long s[200005] = {0}, maxs[200005], res = -1e15, n, b[200005];
void dfs(int p, int u) {
long long m1 = -1e15, m2 = -1e15;
maxs[u] = -1e15;
s[u] = b[u];
for (int i = 0; i < a[u].size(); ++i) {
int v = a[u][i];
if (v == p) continue;... | ### Prompt
Your challenge is to write a Cpp solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They t... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 10;
long long pop(priority_queue<long long> &pq) {
long long x = pq.top();
pq.pop();
return x;
}
void setmax(long long &a, long long b) {
if (a < b) {
a = b;
}
}
int N;
vector<int> adj[MAXN];
long long A[MAXN], sub[MAXN];
long long mxsub... | ### Prompt
Please provide a CPP coded solution to the problem described below:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They t... |
#include <bits/stdc++.h>
using namespace std;
priority_queue<long long int, vector<long long int>, greater<long long int> >
pq;
double startTime;
double getCurrentTime() {
return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}
bool isPrime(long long int n) {
if (n <= 1) return false;
if (n <= 3) return true... | ### Prompt
Your task is to create a Cpp solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took ... |
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
vector<vector<int>> gr;
vector<long long> gifts;
vector<long long> sum;
vector<long long> maxsum;
long long dfs(int v = 0, int p = -1) {
sum[v] = gifts[v];
for (auto to : gr[v])
if (to != p) sum[v] += dfs(to, v);
return sum[v];
}
long l... | ### Prompt
Construct a CPP code solution to the problem outlined:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n prizes ... |
#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n, a[N];
vector<int> edge[N];
vector<long long> subList[N];
long long M[N], res = LLONG_MIN;
void dfs1(int u, int par) {
M[u] = a[u];
for (int i = 0; i < edge[u].size(); i++) {
if (edge[u][i] != par) {
dfs1(edge[u][i], u);
M[u] ... | ### Prompt
Create a solution in cpp for the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n prizes for... |
#include <bits/stdc++.h>
using namespace std;
struct line {
int s, t;
int next;
} a[400001];
int head[200001];
int edge;
inline void add(int s, int t) {
a[edge].next = head[s];
head[s] = edge;
a[edge].s = s;
a[edge].t = t;
}
int fa[200001];
long long sum[200001];
long long maxx[200001];
long long val[200001... | ### Prompt
Construct a Cpp code solution to the problem outlined:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n prizes ... |
#include <bits/stdc++.h>
using namespace std;
int n;
long long pls[1000000];
long long dp[1000000];
long long subsum[1000000];
long long bestsub[1000000];
long long globmax;
long long tempsort[1000000];
vector<int> adjlist[1000000];
void DFS(int node, int parent) {
subsum[node] = pls[node];
bestsub[node] = -1e10;
... | ### Prompt
Please create a solution in Cpp to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n priz... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200 * 1000 + 7;
const long long INF = (long long)1e18;
vector<int> g[MAXN];
int cost[MAXN];
long long sum[MAXN];
long long dp[MAXN];
long long res = -INF;
void dfs(int v, int p = -1) {
sum[v] = cost[v];
dp[v] = -INF;
long long mx1 = -INF, mx2 = -INF;
... | ### Prompt
Develop a solution in CPP to the problem described below:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n priz... |
#include <bits/stdc++.h>
using namespace std;
struct Timer {
chrono::time_point<chrono::high_resolution_clock> start, end;
chrono::duration<float> dur;
Timer() { start = chrono::high_resolution_clock::now(); }
~Timer() {
end = chrono::high_resolution_clock::now();
dur = end - start;
cout << "\nTime ... | ### Prompt
Please create a solution in Cpp to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n priz... |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5;
long long inf = 1e18;
int n;
vector<int> v[N];
vector<int> tree[N];
long long a[N];
long long sm[N];
bool was[N];
long long ans = -1e18;
void podves(int i) {
was[i] = true;
for (int j : v[i])
if (!was[j]) {
tree[i].push_back(j);
podves... | ### Prompt
Your task is to create a cpp solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took ... |
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
struct node {
int v, nxt;
} edge[200010 * 2];
long long dp[200010], sum[200010], w[200010], head[200010], tot, ans;
void add(int u, int v) {
edge[tot].v = v;
edge[tot].nxt = head[u];
head[u] = tot++;
}
void dfs(int u, int fa) {
sum... | ### Prompt
Please formulate a cpp solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n priz... |
#include <bits/stdc++.h>
using namespace std;
const int N = 2 * 1e5 + 10;
const long long INF = 10e18;
vector<int> g[N];
long long scores[N];
bool vis[N];
long long dp[N];
long long sum[N];
int n;
long long ans;
void init() {
for (int i = 1; i <= n; ++i) {
g[i].clear();
}
memset(scores, 0, sizeof(scores));
... | ### Prompt
Your challenge is to write a CPP solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They t... |
#include <bits/stdc++.h>
using namespace std;
const int Maxn = 2e5 + 10;
const long long int inf = 1e18 * -1;
int n;
long long int p[Maxn], d[Maxn], best[Maxn], ans = inf;
bool mark[Maxn];
vector<int> nei[Maxn];
void dfs(int v);
int main() {
cin >> n;
for (int i = 0; i < n; i++) cin >> p[i];
for (int i = 0; i < n... | ### Prompt
In CPP, your task is to solve the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n prizes fo... |
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 5001;
long long int powxy(long long int x, long long int y) {
if (y == 0) return 1;
if (y % 2 == 1) return (x * powxy(x, y - 1)) % mod;
long long int t = powxy(x, y / 2) % mod;
return (t * t) % mod;
}
vector<int> adj[300005];
l... | ### Prompt
Construct a cpp code solution to the problem outlined:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n prizes ... |
#include <bits/stdc++.h>
using namespace std;
int a[200002];
vector<int> G[200002], T[200002];
long long w[200002], best[200002];
void dfs(int root, bool v[]) {
v[root] = true;
for (int u : G[root]) {
if (!v[u]) {
T[root].push_back(u);
dfs(u, v);
}
}
}
void dfs2(int root) {
w[root] = best[ro... | ### Prompt
Your task is to create a Cpp solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took ... |
#include <bits/stdc++.h>
using namespace std;
template <typename T, typename V>
void bugp(const pair<T, V> &x) {
cerr << '{' << x.first << ", " << x.second << '}' << endl;
}
template <typename T, typename U, typename V>
void bugpp(const pair<T, pair<U, V> > &x) {
cerr << '{' << x.first << ", {" << x.second.first <<... | ### Prompt
Create a solution in CPP for the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n prizes for... |
#include <bits/stdc++.h>
using namespace std;
const long long INF = (long long)1e18 + 1l;
const int N = 300300;
long long ans = -INF;
long long a[N];
long long sum[N];
vector<int> g[N];
bool used[N];
void dfs(int v) {
used[v] = 1;
sum[v] = a[v];
a[v] = -INF;
long long m1 = -INF;
long long m2 = -INF;
for (in... | ### Prompt
Please create a solution in cpp to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n priz... |
#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 1;
long long n;
long long a[N];
vector<long long> adj[N];
long long dp[N][2];
long long ans = -1e18;
void dfs(long long src, long long par) {
dp[src][1] = a[src];
dp[src][0] = -1e18;
for (auto it : adj[src]) {
if (it != par) {
dfs(i... | ### Prompt
Your task is to create a cpp solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took ... |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
int n, vs[N];
long long res = INT_MIN;
vector<int> tr[N];
pair<long long, long long> dfs(int curr, int par) {
if (tr[curr].size() == 1 && tr[curr][0] == par) {
return {vs[curr], vs[curr]};
}
long long mx = INT_MIN, mx2 = INT_MIN, sm = vs[cur... | ### Prompt
In Cpp, your task is to solve the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n prizes fo... |
#include <bits/stdc++.h>
using namespace std;
struct node {
long long next;
long long t;
long long w;
} edge[400005];
struct node1 {
long long w;
long long pos;
} p[400005];
long long head[400005], vis[400005];
long long n, tot;
void addedge(long long u, long long v) {
edge[++tot].next = head[u];
edge[tot... | ### Prompt
Please create a solution in CPP to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n priz... |
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18 + 9;
const long long INVALID = -INF;
void fast_io() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
void dfs(int u, int p, vector<vector<int> > &g, vector<long long> &w,
vector<long long> &dp, vector<long long> &dp_s... | ### Prompt
Your challenge is to write a cpp solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They t... |
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e15;
const long long MAXN = 2e5 + 10;
long long val[MAXN], dp[MAXN], ans = -INF;
vector<int> v[MAXN];
void DFS(int x, int y) {
for (int i = 0; i < v[x].size(); i++) {
int u = v[x][i];
if (u == y) continue;
DFS(u, x);
val[x] += val[u]... | ### Prompt
Your challenge is to write a CPP solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They t... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 200005;
const long long inf = 1e15;
long long dp[maxn], num[maxn], ans;
vector<int> G[maxn];
void dfs(int u, int fa) {
for (int i = 0; i < G[u].size(); i++) {
int v = G[u][i];
if (v == fa) continue;
dfs(v, u);
num[u] += num[v];
if (dp[... | ### Prompt
Create a solution in cpp for the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n prizes for... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
const long long INF = 1e15;
vector<int> G[MAXN];
long long a[MAXN], sum[MAXN], dp[MAXN];
long long n, ans = -INF;
void dfs(int u, int fa) {
sum[u] = a[u];
for (int i = 0; i < G[u].size(); i++) {
int v = G[u][i];
if (v == fa) continue;
... | ### Prompt
Create a solution in CPP for the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n prizes for... |
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:66777216")
int mox[8] = {1, -1, 0, 0, 1, -1, 1, -1};
int moy[8] = {0, 0, 1, -1, -1, -1, 1, 1};
char mover[4] = {'D', 'U', 'R', 'L'};
const long long INF = 1LL << 61;
const int inf = 2e9;
const long double PI = acos(-1);
const long double EPS = 1e-9;
bool debug;
u... | ### Prompt
In Cpp, your task is to solve the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n prizes fo... |
#include <bits/stdc++.h>
using namespace std;
const long long INF = 9e18;
int N;
long long ans = -INF;
long long C[200005];
bool visited[200005];
vector<int> adj[200005], Ch[200005];
multiset<long long> SA;
void dfs(int x) {
visited[x] = true;
for (int i = 0; i < adj[x].size(); i++) {
if (!visited[adj[x][i]]) {... | ### Prompt
Your challenge is to write a cpp solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They t... |
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
const int N = 2e5 + 5;
const LL INF = -1e17;
vector<int> g[N];
int n;
LL a[N], ans[N], mx[N], tot[N];
void dp(int u, int p) {
ans[u] = INF, mx[u] = INF, tot[u] = a[u];
LL x = INF, y = INF;
for (auto v : g[u])
if (v... | ### Prompt
Create a solution in CPP for the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n prizes for... |
#include <bits/stdc++.h>
inline long long MAX2(long long a, long long int b) {
return (a) > (b) ? (a) : (b);
}
inline long long MAX3(long long a, long long b, long long c) {
return (a) > (b) ? ((a) > (c) ? (a) : (c)) : ((b) > (c) ? (b) : (c));
}
inline long long MIN2(long long a, long long b) {
return (a) < (b) ?... | ### Prompt
Construct a CPP code solution to the problem outlined:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n prizes ... |
#include <bits/stdc++.h>
using namespace std;
constexpr long long INF = (long long)(2 * 1e15);
vector<vector<int>> graph;
vector<long long> a;
vector<long long> dp1, dp2;
long long ans = -INF;
void dfs(int u, int pr) {
pair<long long, long long> now = make_pair(-INF, -INF);
long long curr = -INF;
dp1[u] = a[u];
... | ### Prompt
Develop a solution in CPP to the problem described below:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n priz... |
#include <bits/stdc++.h>
const int N = 2e5 + 10;
using namespace std;
long long a[N], f[N], flag, res = -2e9;
int n;
vector<int> G[N];
void dfs(int u, int father) {
f[u] = a[u];
for (int i = 0; i < G[u].size(); i++) {
int j = G[u][i];
if (j == father) continue;
dfs(j, u);
f[u] += f[j];
}
}
void df... | ### Prompt
Please formulate a cpp solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n priz... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200005;
const long long INF = 1e18;
vector<int> g[MAXN];
long long a[MAXN], sum[MAXN], cnt[MAXN], dp[MAXN], ans;
void dfs(int v, int parent) {
int to;
sum[v] = a[v];
for (int i = 0; i < g[v].size(); i++) {
to = g[v][i];
if (to == parent) conti... | ### Prompt
Please provide a CPP coded solution to the problem described below:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They t... |
#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e5 + 5;
const long long int inf = -1e15;
bool visit[MAX];
long long int DP[MAX], maxx[MAX], A[MAX], ans;
vector<int> G[MAX];
void dfs(int u, int parent) {
if (visit[u]) return;
visit[u] = 1;
DP[u] = A[u];
maxx[u] = inf;
if (G[u].size() == 1) maxx[... | ### Prompt
Please provide a CPP coded solution to the problem described below:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They t... |
#include <bits/stdc++.h>
using namespace std;
long long v[200005];
vector<int> child[200005];
vector<int> edge[200005];
int parent[200005];
void make_tree(int idx) {
int other;
for (int i = 0; i < edge[idx].size(); i++) {
other = edge[idx][i];
if (parent[other] == -1) {
parent[other] = idx;
chil... | ### Prompt
Your challenge is to write a cpp solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They t... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
const long long INF = 1e15;
vector<vector<int> > g(MAXN, vector<int>());
vector<long long> sums(MAXN, 0);
vector<int> vis(MAXN, 0);
vector<int> was(MAXN, 0);
long long dfs(int u, long long& mx) {
vis[u] = 1;
long long v, currmx = -INF, val;
l... | ### Prompt
Your challenge is to write a Cpp solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They t... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 200001;
vector<int> g[maxn];
long long a[maxn];
int n;
long long ans = -1e18;
bool used[maxn];
long long sum[maxn];
pair<long long, long long> md[maxn];
long long d[maxn];
void dfs(int v) {
used[v] = 1;
sum[v] = a[v];
long long m1 = -1e18;
long long... | ### Prompt
In CPP, your task is to solve the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n prizes fo... |
#include <bits/stdc++.h>
using namespace std;
long long int ans = -(long long int)(1e17 + 1);
vector<long long int> adj[(long long int)(2e5 + 5)],
p((long long int)(2e5 + 5)), dp((long long int)(2e5 + 5));
void dfs(long long int c, long long int pre) {
dp[c] = p[c];
for (auto x : adj[c]) {
if (x == pre) con... | ### Prompt
Develop a solution in cpp to the problem described below:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n priz... |
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long N = 2e5 + 5;
const long long INF = 1e18;
vector<long long> adj[N];
long long sum[N], mx[N];
long long a[N];
long long n;
bool vis[N];
void init() {
for (long long i = 0; i < n; i++) vis[i] = false;
}
long long findsum(long lo... | ### Prompt
Your challenge is to write a CPP solution to the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They t... |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
vector<int> g[N];
long long int a[N], sub[N];
long long int global_ans = -1e18;
bool possible = false;
void subSum(int par, int node) {
sub[node] = a[node];
for (int adj : g[node]) {
if (adj == par) continue;
subSum(node, adj);
sub[nod... | ### Prompt
In CPP, your task is to solve the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n prizes fo... |
#include <bits/stdc++.h>
using namespace std;
long long int MI = (long long int)-1e16;
long long int a[200100];
vector<int> adj[200100];
long long int dp[200100][2];
bool vis[200100];
long long int ans[200100];
void dfs(int v) {
vis[v] = true;
long long int acum = a[v];
vector<int> ch;
for (int i = 0; i < (int)... | ### Prompt
Please provide a Cpp coded solution to the problem described below:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They t... |
#include <bits/stdc++.h>
using namespace std;
vector<long long> graph[200010];
long long n, value[200010];
long long score[200010];
long long mmscore[200010];
bool chk[200010], z;
long long ans = (-300000000000000LL);
long long dfs(long long node) {
chk[node] = true;
long long i, c = 0;
long long s = value[node];... | ### Prompt
Create a solution in cpp for the following problem:
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes.
They took n prizes for... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.