Submission #1123990

#TimeUsernameProblemLanguageResultExecution timeMemory
1123990mychecksedadNewspapers (CEOI21_newspapers)C++17
0 / 100
18 ms27720 KiB
/* Author : Mychecksdead */ #include<bits/stdc++.h> using namespace std; #define ll long long int #define MOD (1000000000+7) #define MOD1 (998244353) #define pb push_back #define all(x) x.begin(), x.end() #define en cout << '\n' #define ff first #define ss second #define pii pair<int,int> #define vi vector<int> const int N = 1e6+100, M = 1e5+10, K = 52, MX = 30; int n, m, o =0, oo = 0; vector<int> g[N]; bool no = 0; vector<int> vis(N); void dfs(int v, int p){ for(int u: g[v]){ if(u != p){ if(g[u].size() > 1) no = 1; dfs(u, v); } } } void solve(){ cin >> n >> m; for(int i = 1; i <= m; ++i){ int u, v; cin >> u >> v; g[u].pb(v); g[v].pb(u); } vis[1] = 1; if(m >= n){ cout << "NO"; }else{ for(int i = 1; i <= n; ++i){ if(g[i].size()>1){ dfs(i, i); break; } } if(no){ cout << "NO"; }else{ cout << "YES\n"; cout << "1\n1"; } } } int main(){ cin.tie(0); ios::sync_with_stdio(0); int tt = 1, aa; // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); while(tt--){ solve(); } cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" seconds\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...