Submission #999178

#TimeUsernameProblemLanguageResultExecution timeMemory
999178IdanRosenNewspapers (CEOI21_newspapers)C++98
4 / 100
1 ms604 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<ll, ll> pll; typedef pair<ld, ld> pld; vector<vector<ll>> adj; bool cycle = false; vector<bool> vis; void search(int node, int prev = -1) { vis[node] = true; for (ll nei : adj[node]) { if (nei == prev) continue; if (vis[nei]) { cycle = true; break; } search(nei, node); } } int main() { ios_base::sync_with_stdio(false); cout.tie(nullptr); cin.tie(nullptr); ll n, m; cin >> n >> m; adj.resize(n); for (int i = 0; i < m; i++) { ll a, b; cin >> a >> b; a--; b--; adj[a].push_back(b); adj[b].push_back(a); } vis.resize(n, false); search(0); if (cycle) { cout << "NO\n"; } else { cout << "YES\n"; cout << "1\n1\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...