제출 #666760

#제출 시각아이디문제언어결과실행 시간메모리
666760divadNetwork (BOI15_net)C++14
0 / 100
7 ms12056 KiB
#include <iostream> #include <algorithm> #include <vector> #define MAX 500002 using namespace std; int n,x,y,vf[MAX]; vector<int> v[MAX],frunze; void dfs(int nod){ vf[nod] = 1; bool ok = false; for(auto vecin: v[nod]){ if(vf[vecin] == 0){ ok |= true; dfs(vecin); } } if(!ok){ frunze.push_back(nod); } } int main() { cin >> n; for(int i = 1; i < n; i++){ cin >> x >> y; v[x].push_back(y); v[y].push_back(x); } dfs(1); sort(frunze.begin(), frunze.end()); cout << frunze.size()-1 << "\n"; cout << "1 " << frunze[0] << "\n"; for(int i = 1; i < frunze.size()-1; i++){ cout << frunze[i] << " " << frunze[i+1] << "\n"; } return 0; }

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

net.cpp: In function 'int main()':
net.cpp:35:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     for(int i = 1; i < frunze.size()-1; i++){
      |                    ~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...