Submission #1277900

#TimeUsernameProblemLanguageResultExecution timeMemory
1277900negar_aNewspapers (CEOI21_newspapers)C++20
4 / 100
2 ms676 KiB
#include<bits/stdc++.h> using namespace std; const int maxn = 1e3 + 10; vector <int> adj[maxn]; bool mark[maxn]; bool mar[maxn]; int par[maxn]; bool cycle = false; void dfs(int u){ mark[u] = true; for(auto v: adj[u]){ if(!mark[v]){ par[v] = u; dfs(v); } else{ if(v != par[u]){ cycle = true; } } } } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, m; cin >> n >> m; for(int i = 0; i < m; i ++){ int u, v; cin >> u >> v; u --; v --; adj[u].push_back(v); adj[v].push_back(u); } dfs(0); int x = 0; for(int i = 0; i < n; i ++){ if(adj[i].size() == 1){ x = i; } } if(cycle){ cout << "NO"; } else{ cout << "YES" << endl; cout << 4 * n + 1 << endl; for(int i = 1; i <= n; i ++){ cout << i << " " << i << " "; } cout << n << " "; for(int i = 1; i <= n; i ++){ cout << i << " " << i << " "; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...