Submission #1084960

#TimeUsernameProblemLanguageResultExecution timeMemory
1084960TheGreatAntivirusNetwork (BOI15_net)C++17
63 / 100
5 ms10076 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define stdI freopen("input.txt", "r", stdin); #define stdO freopen("output.txt", "w", stdout); #define all(x) x.begin(), x.end() #define mp(x, y) make_pair(x, y) #define int long long #define F first #define S second using namespace std; using namespace __gnu_pbds; typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; typedef pair<int, int> pii; const int MAXN = 2e5 + 100, INF = 1e18, MOD = 1e9 + 7; vector<int> adj[MAXN]; vector<int> b; int n; void dfs(int v, int p) { if(adj[v].size() == 1) { b.push_back(v); } for(auto u : adj[v]) { if(u != p) { dfs(u, v); } } } void solve() { cin >> n; for(int i = 1; i < n; i++) { int u, v; cin >> u >> v; adj[u].push_back(v); adj[v].push_back(u); } dfs(1, 0); if(b.size() & 1) { b.push_back(b[0]); } cout << b.size() / 2 << "\n"; for(int i = 0; i < b.size() / 2; i++) { cout << b[i] << " " << b[b.size() / 2 + i] << "\n"; } } int32_t main() { IOS; int t = 1; //cin >> t; while(t--) { solve(); } return 0; }

Compilation message (stderr)

net.cpp: In function 'void solve()':
net.cpp:57:22: 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]
   57 |     for(int i = 0; i < b.size() / 2; i++)
      |                    ~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...