Submission #111406

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
1114062019-05-15 07:29:13diamond_dukeFireworks (APIO16_fireworks)C++11
100 / 100
609 ms16504 KiB
#include <algorithm>
#include <cstdio>
using ll = long long;
int lson[1200005], rson[1200005], dep[1200005], t_cnt;
ll val[1200005];
int merge(int u, int v)
{
if (!u || !v)
return u | v;
if (val[u] < val[v])
std::swap(u, v);
rson[u] = merge(rson[u], v);
if (dep[lson[u]] < dep[rson[u]])
std::swap(lson[u], rson[u]);
dep[u] = rson[u] ? dep[rson[u]] + 1 : 0;
return u;
}
inline int new_node(ll x) { val[++t_cnt] = x; return t_cnt; }
void pop(int &u) { u = merge(lson[u], rson[u]); }
int fa[600005], faw[600005], deg[600005], rt[600005];
int main()
{
// freopen("uoj-205.in", "r", stdin);
int n, m;
scanf("%d%d", &n, &m);
ll ans = 0;
for (int i = 1; i < n + m; i++)
{
scanf("%d%d", fa + i, faw + i);
deg[--fa[i]]++;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

fireworks.cpp: In function 'int main()':
fireworks.cpp:25:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~
fireworks.cpp:29:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", fa + i, faw + 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...