제출 #1277815

#제출 시각아이디문제언어결과실행 시간메모리
1277815negar_aNewspapers (CEOI21_newspapers)C++20
0 / 100
1 ms336 KiB
#include<bits/stdc++.h> using namespace std; const int maxn = 1e3 + 10; vector <int> adj[maxn]; bool mark[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); if(cycle){ cout << "NO"; } else{ cout << "YES"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...