This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <vector>
#include <iostream>
using namespace std;
int N,k;
vector<int> bad,ans;
bool rec(int node, int cur) {
if (cur == k) {
//a.push_back(node);
return true;
}
if (node < 1 || node > N) return false;
if (ans[cur] == node) return false;
if (rec(node-1, cur+1)) {
bad.push_back(node);
return true;
}
if (rec(node+1, cur+1)) {
bad.push_back(node);
return true;
}
return false;
}
bool ok = true;
void dfs(int par, int node, vector<int> &vis, vector<vector<int>> &adj) {
vis[node] = 1;
for (int u : adj[node]) {
if (u == par) continue;
if (vis[u] == 0) dfs(node, u, vis, adj);
if (vis[u] == 1) ok = false;
}
vis[node] = 2;
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(nullptr);
int n,m,a,b; cin >> n >> m;
vector<vector<int>> adj(n);
while (m--) {
cin >> a >> b;
adj[--a].push_back(--b);
adj[b].push_back(a);
}
vector<int> vis(n);
dfs(0,0,vis, adj);
cout << (ok ? "YES\n1\n1" : "NO");
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |