Submission #469740

# Submission time Handle Problem Language Result Execution time Memory
469740 2021-09-01T16:56:13 Z blue Cat in a tree (BOI17_catinatree) C++17
Compilation error
0 ms 0 KB
#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],max(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=a.z+2;--x;;)if(x<q.z)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];}

Compilation message

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],max(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=a.z+2;--x;;)if(x<q.z)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:183: 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],max(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=a.z+2;--x;;)if(x<q.z)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:214: 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],max(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=a.z+2;--x;;)if(x<q.z)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:254: error: expected primary-expression before ';' token
    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],max(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=a.z+2;--x;;)if(x<q.z)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:254: error: expected ')' before ';' token
    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],max(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=a.z+2;--x;;)if(x<q.z)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:255: error: expected primary-expression before ')' token
    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],max(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=a.z+2;--x;;)if(x<q.z)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];}
      |                                                                                                                                                                                                                                                               ^