제출 #469743

#제출 시각아이디문제언어결과실행 시간메모리
469743blueCat in a tree (BOI17_catinatree)C++17
100 / 100
268 ms217792 KiB
#include<bits/stdc++.h> #define z size() using namespace std;int N,D,x,i;deque<int>c[200000];deque<int>d(int u){deque<int>q(1,1);for(int v:c[u]){auto a=d(v);if(q.z<a.z)swap(q,a);for(x=0;x<a.z;x++)q[x]=max({q[x],a[x]+(D-x<q.z?q[max(D-x,x)]:0),q[x]+(D-x<a.z?a[max(D-x,x)]:0)});for(x=min(a.z+2,q.z);--x;)q[x-1]=max(q[x-1],q[x]);}q.push_front(q.front());return q;}int main(){cin>>N>>D;for(i=1;i<N;i++){cin>>x;c[x].push_back(i);}cout<<d(0)[0];}

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

catinatree.cpp: In function 'std::deque<int> d(int)':
catinatree.cpp:3:147: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    3 | using namespace std;int N,D,x,i;deque<int>c[200000];deque<int>d(int u){deque<int>q(1,1);for(int v:c[u]){auto a=d(v);if(q.z<a.z)swap(q,a);for(x=0;x<a.z;x++)q[x]=max({q[x],a[x]+(D-x<q.z?q[max(D-x,x)]:0),q[x]+(D-x<a.z?a[max(D-x,x)]:0)});for(x=min(a.z+2,q.z);--x;)q[x-1]=max(q[x-1],q[x]);}q.push_front(q.front());return q;}int main(){cin>>N>>D;for(i=1;i<N;i++){cin>>x;c[x].push_back(i);}cout<<d(0)[0];}
      |                                                                                                                                                   ^
catinatree.cpp:3:180: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    3 | using namespace std;int N,D,x,i;deque<int>c[200000];deque<int>d(int u){deque<int>q(1,1);for(int v:c[u]){auto a=d(v);if(q.z<a.z)swap(q,a);for(x=0;x<a.z;x++)q[x]=max({q[x],a[x]+(D-x<q.z?q[max(D-x,x)]:0),q[x]+(D-x<a.z?a[max(D-x,x)]:0)});for(x=min(a.z+2,q.z);--x;)q[x-1]=max(q[x-1],q[x]);}q.push_front(q.front());return q;}int main(){cin>>N>>D;for(i=1;i<N;i++){cin>>x;c[x].push_back(i);}cout<<d(0)[0];}
      |                                                                                                                                                                                    ^
catinatree.cpp:3:211: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    3 | using namespace std;int N,D,x,i;deque<int>c[200000];deque<int>d(int u){deque<int>q(1,1);for(int v:c[u]){auto a=d(v);if(q.z<a.z)swap(q,a);for(x=0;x<a.z;x++)q[x]=max({q[x],a[x]+(D-x<q.z?q[max(D-x,x)]:0),q[x]+(D-x<a.z?a[max(D-x,x)]:0)});for(x=min(a.z+2,q.z);--x;)q[x-1]=max(q[x-1],q[x]);}q.push_front(q.front());return q;}int main(){cin>>N>>D;for(i=1;i<N;i++){cin>>x;c[x].push_back(i);}cout<<d(0)[0];}
      |                                                                                                                                                                                                                   ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...