Submission #242307

#TimeUsernameProblemLanguageResultExecution timeMemory
242307dantoh000Magic Tree (CEOI19_magictree)C++14
0 / 100
73 ms5368 KiB
#include <bits/stdc++.h> using namespace std; int n,m,k; int p[100005]; vector<int> G[100005]; int a[100005]; int L[100005]; int ans = 0; int main(){ scanf("%d%d%d",&n,&m,&k); for (int i = 2; i <= n; i++){ scanf("%d",&p[i]); G[p[i]].push_back(i); } for (int i = 0; i < m; i++){ int v,d,w; scanf("%d%d%d",&v,&d,&w); a[v] = d; } for (int i = 1; i <= n; i++){ a[i] += (n-i); } for (int i = n; i >= 1; i--){ if (a[i] == n-i) continue; int pos = lower_bound(L,L+ans,a[i])-L; L[pos] = a[i]; ans = max(ans,pos+1); } printf("%d",ans); //dfs(1,-1); //printf("%d",dp1[]; }

Compilation message (stderr)

magictree.cpp: In function 'int main()':
magictree.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d",&n,&m,&k);
     ~~~~~^~~~~~~~~~~~~~~~~~~
magictree.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&p[i]);
         ~~~~~^~~~~~~~~~~~
magictree.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d",&v,&d,&w);
         ~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...