제출 #1039044

#제출 시각아이디문제언어결과실행 시간메모리
1039044HanksburgerCat in a tree (BOI17_catinatree)C++17
100 / 100
58 ms20584 KiB
#include <bits/stdc++.h> using namespace std; vector<int>j[200005]; int n,d,s,x; int f(int u) { s++; vector<int>a(1,0); for (int v:j[u]) a.push_back(f(v)+1); sort(a.begin(),a.end()); int m=0; while (m+1<a.size()&&a[m]+a[m+1]<d) m++,s--; return a[m]; } int main() { cin>>n>>d; for(int i=1;i<n;i++) cin>>x,j[x].push_back(i); f(0); cout<<s; }

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

catinatree.cpp: In function 'int f(int)':
catinatree.cpp:13:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     while (m+1<a.size()&&a[m]+a[m+1]<d)
      |            ~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...