제출 #932992

#제출 시각아이디문제언어결과실행 시간메모리
932992ArashJafariyanNetwork (BOI15_net)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #ifdef DEBUG #include "debug.h" #else #define debug(...) 0 #endif typedef long long ll; int main() { std::ios::sync_with_stdio(0); std::cin.tie(0); int n; std::cin >> n; std::vector<std::vector<int>> adj(n); for (int i = 1; i < n; i++) { int v, u; std::cin >> v >> u; v--; u--; adj[v].push_back(u); adj[u].push_back(v); } std::vector<int> leaf; auto dfs = [&](auto self, int v, int p) -> void { if (adj[v].size() == 1) { leaf.push_back(v); } for (int u : adj[v]) { if (u != p) { self(self, u, v); } } }; dfs(dfs, 0, 0); int sz = leaf.size(); cout << (sz + 1) / 2 << '\n'; for (int i = 0; i + sz / 2 < sz; i++) { std::cout << leaf[i] + 1 << ' ' << leaf[i + sz / 2] + 1 << '\n'; } return 0; }

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

net.cpp: In function 'int main()':
net.cpp:41:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   41 |     cout << (sz + 1) / 2 << '\n';
      |     ^~~~
      |     std::cout
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:75,
                 from net.cpp:1:
/usr/include/c++/10/iostream:61:18: note: 'std::cout' declared here
   61 |   extern ostream cout;  /// Linked to standard output
      |                  ^~~~