제출 #476080

#제출 시각아이디문제언어결과실행 시간메모리
476080ZaZo_Network (BOI15_net)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define HID ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define int long long #define all(v) v.begin(),v.end() const int N = 500005 , INF = 1e15 , MOD=1000000006; using namespace std; int n ; vector<int>edges[N]; vector<int>leaves; void dfs(int node,int par) { if(edges[node].size()==1) leaves.push_back(node); for(auto x : edges[node]) if(x!=par) dfs(x,node); } int32_t main() { HID cin>>n; for(int i = 0 ; i < n-1 ; i++) { int u , v; cin >> u >> v; edges[u].push_back(v); edges[v].push_back(u); } dfs(1); cout<<(leaves.size()+1)/2<<endl; if(leaves.size()%2==0) { for(int i = 0 ; i < leaves.size() ; i+=2) { cout<<leaves[i]<<" "<<leaves[i+1]<<endl; } } else { for(int i = 0 ; i < leaves.size() ; i+=2) { if(i==leaves.size()-1) break; cout<<leaves[i]<<" "<<leaves[i+1]<<endl; } cout<<leaves.back()<<" "; for(int i = 1 ; i <= n ; i++) { if(i!=leaves.back()&&i!=edges[leaves.back()][0]) { cout<<i<<endl; } break; } } }

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

net.cpp: In function 'int32_t main()':
net.cpp:27:8: error: too few arguments to function 'void dfs(long long int, long long int)'
   27 |   dfs(1);
      |        ^
net.cpp:10:6: note: declared here
   10 | void dfs(int node,int par)
      |      ^~~
net.cpp:31:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for(int i = 0 ; i < leaves.size() ; i+=2)
      |                     ~~^~~~~~~~~~~~~~~
net.cpp:38:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for(int i = 0 ; i < leaves.size() ; i+=2)
      |                     ~~^~~~~~~~~~~~~~~
net.cpp:40:11: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |       if(i==leaves.size()-1)  break;
      |          ~^~~~~~~~~~~~~~~~~