# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
898947 | vjudge1 | Magic Tree (CEOI19_magictree) | C++17 | Compilation error | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define dbg(x) cout << "reached here " << x << endl;
#define ll long long
using namespace std;
typedef pair<int, int> pii;
const int maxn = 2e5+5;
int a[maxn];
vector<int> adj[maxn];
map<int, int> sack[maxn];
void merge(int v, int u)
{
for (auto e: sack[u])
sack[v][e.f] += e.s;
}
void dfs(int v)
{
for(auto u: adj[v])
{
dfs(u);
if(sack[u].size() > sack[v].size())
sack[v].swap(sack[u]);
}
for (auto u: adj[v])
merge(v, u);
if(a[v])
{
int h = 0;
auto it = sack[v].rbegin();
if(sack[v].size() > 0)
if((*it).f > a[v])
h += (*it).s;
if(sack[v].size() > 1)
{
auto it3 = sack[v].rbegin();
it3--;
if((*it3).f > a[v])
h += (*it3).s;
}
if(h <= 1)
{
auto it2 = sack[v].rbegin();
sack[v][a[v]]++;
while((*it2).f > a[v] and it2 != sack[v].rend())
{
auto del = sack[v].find((*it2).f);
sack[v].erase(del);
it2++;
}
}
}
}
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, m, k;
cin >> n >> m >> k;
for (int i = 2; i <= n; ++i)
{
int p;
cin >> p;
adj[p].pb(i);
}
for (int i = 1; i <= m; ++i)
{
int v, d, w;
cin >> v >> d >> w;
a[v] = d;
}
dfs(1);
int ans = 0;
for (auto u: sack[1])
ans += u.s;
cout << ans << endl;
return 0;
}
Compilation message (stderr)
magictree.cpp:18:1: error: extended character is not valid in an identifier 18 | for (auto e: sack[u]) | ^ magictree.cpp:18:1: error: extended character is not valid in an identifier magictree.cpp:18:1: error: extended character is not valid in an identifier magictree.cpp:19:1: error: extended character is not valid in an identifier 19 | sack[v][e.f] += e.s; | ^ magictree.cpp:19:1: error: extended character is not valid in an identifier magictree.cpp:19:1: error: extended character is not valid in an identifier magictree.cpp:19:1: error: extended character is not valid in an identifier magictree.cpp:19:1: error: extended character is not valid in an identifier magictree.cpp:19:1: error: extended character is not valid in an identifier magictree.cpp:19:1: error: extended character is not valid in an identifier magictree.cpp:25:1: error: extended character is not valid in an identifier 25 | for(auto u: adj[v]) | ^ magictree.cpp:25:1: error: extended character is not valid in an identifier magictree.cpp:25:1: error: extended character is not valid in an identifier magictree.cpp:26:1: error: extended character is not valid in an identifier 26 | { | ^ magictree.cpp:26:1: error: extended character is not valid in an identifier magictree.cpp:26:1: error: extended character is not valid in an identifier magictree.cpp:27:1: error: extended character is not valid in an identifier 27 | dfs(u); | ^ magictree.cpp:27:1: error: extended character is not valid in an identifier magictree.cpp:27:1: error: extended character is not valid in an identifier magictree.cpp:27:1: error: extended character is not valid in an identifier magictree.cpp:27:1: error: extended character is not valid in an identifier magictree.cpp:27:1: error: extended character is not valid in an identifier magictree.cpp:27:1: error: extended character is not valid in an identifier magictree.cpp:28:1: error: extended character is not valid in an identifier 28 | if(sack[u].size() > sack[v].size()) | ^ magictree.cpp:28:1: error: extended character is not valid in an identifier magictree.cpp:28:1: error: extended character is not valid in an identifier magictree.cpp:28:1: error: extended character is not valid in an identifier magictree.cpp:28:1: error: extended character is not valid in an identifier magictree.cpp:28:1: error: extended character is not valid in an identifier magictree.cpp:28:1: error: extended character is not valid in an identifier magictree.cpp:29:1: error: extended character is not valid in an identifier 29 | sack[v].swap(sack[u]); | ^ magictree.cpp:29:1: error: extended character is not valid in an identifier magictree.cpp:29:1: error: extended character is not valid in an identifier magictree.cpp:29:1: error: extended character is not valid in an identifier magictree.cpp:29:1: error: extended character is not valid in an identifier magictree.cpp:29:1: error: extended character is not valid in an identifier magictree.cpp:29:1: error: extended character is not valid in an identifier magictree.cpp:29:1: error: extended character is not valid in an identifier magictree.cpp:29:1: error: extended character is not valid in an identifier magictree.cpp:29:1: error: extended character is not valid in an identifier magictree.cpp:29:1: error: extended character is not valid in an identifier magictree.cpp:30:1: error: extended character is not valid in an identifier 30 | } | ^ magictree.cpp:30:1: error: extended character is not valid in an identifier magictree.cpp:30:1: error: extended character is not valid in an identifier magictree.cpp:32:1: error: extended character is not valid in an identifier 32 | for (auto u: adj[v]) | ^ magictree.cpp:32:1: error: extended character is not valid in an identifier magictree.cpp:32:1: error: extended character is not valid in an identifier magictree.cpp:33:1: error: extended character is not valid in an identifier 33 | merge(v, u); | ^ magictree.cpp:33:1: error: extended character is not valid in an identifier magictree.cpp:33:1: error: extended character is not valid in an identifier magictree.cpp:33:1: error: extended character is not valid in an identifier magictree.cpp:33:1: error: extended character is not valid in an identifier magictree.cpp:33:1: error: extended character is not valid in an identifier magictree.cpp:33:1: error: extended character is not valid in an identifier magictree.cpp:33:28: error: extended character is not valid in an identifier 33 | merge(v, u); | ^ magictree.cpp:33:28: error: extended character is not valid in an identifier magictree.cpp:33:28: error: extended character is not valid in an identifier magictree.cpp:33:28: error: extended character is not valid in an identifier magictree.cpp:33:28: error: extended character is not valid in an identifier magictree.cpp:33:28: error: extended character is not valid in an identifier magictree.cpp:36:1: error: extended character is not valid in an identifier 36 | if(a[v]) | ^ magictree.cpp:36:1: error: extended character is not valid in an identifier magictree.cpp:36:1: error: extended character is not valid in an identifier magictree.cpp:37:1: error: extended character is not valid in an identifier 37 | { | ^ magictree.cpp:37:1: error: extended character is not valid in an identifier magictree.cpp:37:1: error: extended character is not valid in an identifier magictree.cpp:38:1: error: extended character is not valid in an identifier 38 | int h = 0; | ^ magictree.cpp:38:1: error: extended character is not valid in an identifier magictree.cpp:38:1: error: extended character is not valid in an identifier magictree.cpp:38:1: error: extended character is not valid in an identifier magictree.cpp:38:1: error: extended character is not valid in an identifier magictree.cpp:38:1: error: extended character is not valid in an identifier magictree.cpp:38:1: error: extended character is not valid in an identifier magictree.cpp:39:1: error: extended character is not valid in an identifier 39 | auto it = sack[v].rbegin(); | ^ magictree.cpp:39:1: error: extended character is not valid in an identifier magictree.cpp:39:1: error: extended character is not valid in an identifier magictree.cpp:39:1: error: extended character is not valid in an identifier magictree.cpp:39:1: error: extended character is not valid in an identifier magictree.cpp:39:1: error: extended character is not valid in an identifier magictree.cpp:39:1: error: extended character is not valid in an identifier magictree.cpp:40:1: error: extended character is not valid in an identifier 40 | if(sack[v].size() > 0) | ^ magictree.cpp:40:1: error: extended character is not valid in an identifier magictree.cpp:40:1: error: extended character is not valid in an identifier magictree.cpp:40:1: error: extended character is not valid in an identifier magictree.cpp:40:1: error: extended character is not valid in an identifier magictree.cpp:40:1: error: extended character is not valid in an identifier magictree.cpp:40:1: error: extended character is not valid in an identifier magictree.cpp:41:1: error: extended character is not valid in an identifier 41 | if((*it).f > a[v]) | ^ magictree.cpp:41:1: error: extended character is not valid in an identifier magictree.cpp:41:1: error: extended character is not valid in an identifier magictree.cpp:41:1: error: extended character is not valid in an identifier magictree.cpp:41:1: error: extended character is not valid in an identifier magictree.cpp:41:1: error: extended character is not valid in an identifier magictree.cpp:41:1: error: extended character is not valid in an identifier magictree.cpp:41:1: error: extended character is not valid in an identifier magictree.cpp:41:1: error: extended character is not valid in an identifier magictree.cpp:41:1: error: extended character is not valid in an identifier magictree.cpp:41:1: error: extended character is not valid in an identifier magictree.cpp:42:1: error: extended character is not valid in an identifier 42 | h += (*it).s; | ^ magictree.cpp:42:1: error: extended character is not valid in an identifier magictree.cpp:42:1: error: extended character is not valid in an identifier magictree.cpp:42:1: error: extended character is not valid in an identifier magictree.cpp:42:1: error: extended character is not valid in an identifier magictree.cpp:42:1: error: extended character is not valid in an identifier magictree.cpp:42:1: error: extended character is not valid in an identifier magictree.cpp:42:1: error: extended character is not valid in an identifier magictree.cpp:42:1: error: extended character is not valid in an identifier magictree.cpp:42:1: error: extended character is not valid in an identifier magictree.cpp:42:1: error: extended character is not valid in an identifier magictree.cpp:42:1: error: extended character is not valid in an identifier magictree.cpp:42:1: error: extended character is not valid in an identifier magictree.cpp:42:1: error: extended character is not valid in an identifier magictree.cpp:42:1: error: extended character is not valid in an identifier magictree.cpp:44:1: error: extended character is not valid in an identifier 44 | if(sack[v].size() > 1) | ^ magictree.cpp:44:1: error: extended character is not valid in an identifier magictree.cpp:44:1: error: extended character is not valid in an identifier magictree.cpp:44:1: error: extended character is not valid in an identifier magictree.cpp:44:1: error: extended character is not valid in an identifier magictree.cpp:44:1: error: extended character is not valid in an identifier magictree.cpp:44:1: error: extended character is not valid in an identifier magictree.cpp:45:1: error: extended character is not valid in an identifier 45 | { | ^ magictree.cpp:45:1: error: extended character is not valid in an identifier magictree.cpp:45:1: error: extended character is not valid in an identifier magictree.cpp:45:1: error: extended character is not valid in an identifier magictree.cpp:45:1: error: extended character is not valid in an identifier magictree.cpp:45:1: error: extended character is not valid in an identifier magictree.cpp:45:1: error: extended character is not valid in an identifier magictree.cpp:46:1: error: extended character is not valid in an identifier 46 | auto it3 = sack[v].rbegin(); | ^ magictree.cpp:46:1: error: extended character is not valid in an identifier magictree.cpp:46:1: error: extended character is not valid in an identifier magictree.cpp:46:1: error: extended character is not valid in an identifier magictree.cpp:46:1: error: extended character is not valid in an identifier magictree.cpp:46:1: error: extended character is not valid in an identifier magictree.cpp:46:1: error: extended character is not valid in an identifier magictree.cpp:46:1: error: extended character is not valid in an identifier magictree.cpp:46:1: error: extended character is not valid in an identifier magictree.cpp:46:1: error: extended character is not valid in an identifier magictree.cpp:46:1: error: extended character is not valid in an identifier magictree.cpp:47:1: error: extended character is not valid in an identifier 47 | it3--; | ^ magictree.cpp:47:1: error: extended character is not valid in an identifier magictree.cpp:47:1: error: extended character is not valid in an identifier magictree.cpp:47:1: error: extended character is not valid in an identifier magictree.cpp:47:1: error: extended character is not valid in an identifier magictree.cpp:47:1: error: extended character is not valid in an identifier magictree.cpp:47:1: error: extended character is not valid in an identifier magictree.cpp:47:1: error: extended character is not valid in an identifier magictree.cpp:47:1: error: extended character is not valid in an identifier magictree.cpp:47:1: error: extended character is not valid in an identifier magictree.cpp:47:1: error: extended character is not valid in an identifier magictree.cpp:47:1: error: extended character is not valid in an identifier magictree.cpp:48:1: error: extended character is not valid in an identifier 48 | if((*it3).f > a[v]) | ^ magictree.cpp:48:1: error: extended character is not valid in an identifier magictree.cpp:48:1: error: extended character is not valid in an identifier magictree.cpp:48:1: error: extended character is not valid in an identifier magictree.cpp:48:1: error: extended character is not valid in an identifier magictree.cpp:48:1: error: extended character is not valid in an identifier magictree.cpp:48:1: error: extended character is not valid in an identifier magictree.cpp:48:1: error: extended character is not valid in an identifier magictree.cpp:48:1: error: extended character is not valid in an identifier magictree.cpp:48:1: error: extended character is not valid in an identifier magictree.cpp:48:1: error: extended character is not valid in an identifier magictree.cpp:49:1: error: extended character is not valid in an identifier 49 | h += (*it3).s; | ^ magictree.cpp:49:1: error: extended character is not valid in an identifier magictree.cpp:49:1: error: extended character is not valid in an identifier magictree.cpp:49:1: error: extended character is not valid in an identifier magictree.cpp:49:1: error: extended character is not valid in an identifier magictree.cpp:49:1: error: extended character is not valid in an identifier magictree.cpp:49:1: error: extended character is not valid in an identifier magictree.cpp:49:1: error: extended character is not valid in an identifier magictree.cpp:49:1: error: extended character is not valid in an identifier magictree.cpp:49:1: error: extended character is not valid in an identifier magictree.cpp:49:1: error: extended character is not valid in an identifier magictree.cpp:49:1: error: extended character is not valid in an identifier magictree.cpp:49:1: error: extended character is not valid in an identifier magictree.cpp:49:1: error: extended character is not valid in an identifier magictree.cpp:49:1: error: extended character is not valid in an identifier magictree.cpp:50:1: error: extended character is not valid in an identifier 50 | } | ^ magictree.cpp:50:1: error: extended character is not valid in an identifier magictree.cpp:50:1: error: extended character is not valid in an identifier magictree.cpp:50:1: error: extended character is not valid in an identifier /var/local/lib/iso