답안 #242315

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
242315 2020-06-27T08:44:13 Z dantoh000 Magic Tree (CEOI19_magictree) C++14
11 / 100
74 ms 6904 KB
#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 = 0; i <= n; i++) L[i] = 1000000005;
    for (int i = n; i >= 1; i--){
        if (a[i] == 0) continue;
        int pos = upper_bound(L,L+ans,a[i])-L;
        //printf("%d goes %d\n",a[i],pos);
        L[pos] = a[i];
        ans = max(ans,pos+1);
    }
    printf("%d",ans);
    //dfs(1,-1);
    //printf("%d",dp1[];
}

Compilation message

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);
         ~~~~~^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 43 ms 5240 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 7 ms 2688 KB Output is correct
3 Correct 6 ms 2688 KB Output is correct
4 Correct 56 ms 6904 KB Output is correct
5 Correct 57 ms 6904 KB Output is correct
6 Correct 62 ms 6904 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 74 ms 5624 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 3200 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -