제출 #745522

#제출 시각아이디문제언어결과실행 시간메모리
745522SarpaNewspapers (CEOI21_newspapers)C++14
4 / 100
5 ms5076 KiB
// Be nam KHODA
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define all(x) (x).begin(), (x).end()
#define F first
#define S second

const int N = 2e5 + 10, mod = 1e9 + 7, inf = INT_MAX;

int n, m;
vector<int> adj[N];
bool mark[N], cy;
int color[N];

void dfs(int u, int p = -1){
  mark[u] = true;
  if(p != -1) color[u] = color[p]^1;
  for(auto & v : adj[u]){
    if(mark[v] and color[u] == color[v])
      cy = true;
    if(!mark[v])
      dfs(v, u);
    }
}

int main(){
    cin.tie(0), ios::sync_with_stdio(0);
    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(cy)
      cout << "NO" << endl;
    else
      cout << "YES\n1\n1" << endl;
    return 0;   
}




#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...