제출 #242260

#제출 시각아이디문제언어결과실행 시간메모리
242260tqbfjotldMagic Tree (CEOI19_magictree)C++14
11 / 100
65 ms3060 KiB
#include <bits/stdc++.h>
using namespace std;

int n,m,k;
int p[100005];
int d[100005];
long long w[100005];

int main(){
    scanf("%d%d%d",&n,&m,&k);
    for (int x = 1; x<n; x++){
        scanf("%d",&p[x]);
        p[x]--;
    }
    for (int x = 0; x<m; x++){
        int a,b;
        long long c;
        scanf("%d%d%lld",&a,&b,&c);
        a--;
        d[a] = b;
        w[a] = c;
    }
    vector<int> v;
    for (int x = 0; x<n; x++){
        if (w[x]==0) continue;
        if (v.empty()) v.push_back(-d[x]);
        else if (-d[x]>=v[(int)v.size()-1]){
            v.push_back(-d[x]);
        }
        else{
            int pos = upper_bound(v.begin(),v.end(),-d[x])-v.begin();
            v[pos] = -d[x];
        }
    }
    printf("%d",v.size());

}

컴파일 시 표준 에러 (stderr) 메시지

magictree.cpp: In function 'int main()':
magictree.cpp:35:25: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
     printf("%d",v.size());
                 ~~~~~~~~^
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[x]);
         ~~~~~^~~~~~~~~~~~
magictree.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%lld",&a,&b,&c);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~
#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...