답안 #1114564

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1114564 2024-11-19T08:04:41 Z vjudge1 Newspapers (CEOI21_newspapers) C++17
0 / 100
1 ms 336 KB
//Dost SEFEROĞLU
#include <bits/stdc++.h>
#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")
using namespace std;
#define int long long
#define pii pair<int,int>
#define ff first
#define ss second
#define sp << " " <<    
#define all(cont) cont.begin(),cont.end()
#define vi vector<int>
const int MOD = 1e9+7,inf = 2e18;
const int N = 2e5+50,Q = 2e5+50;
const int B = 500;


void solve() { 
    int n,m;
    cin >> n >> m;
    if (m > n-1) {
        cout << "NO\n";
        return;
    }
    vi deg(n+1,0);
    for (int i=1;i<=m;i++) {
        int a,b;
        cin >> a >> b;
        deg[a]++,deg[b]++;
    }
    int cnt = 0,fnd;
    for (int i=1;i<=n;i++) {
        if (deg[i] >= 2) {
            cnt++;
            fnd =  i;
        }
    }
    if (cnt > 1) {
        cout << "NO\n";
        return;
    } 
    cout << "YES\n";
    cout << 2 <<'\n';
    cout << fnd << ' ' << fnd << '\n';
}                    
                             
signed main() { 
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifdef Dodi
        freopen("in.txt","r",stdin);
        freopen("out.txt","w",stdout);
    #endif
    int t = 1;
    //cin >> t; 
    while (t --> 0) solve();
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB Integer 0 violates the range [1, 1]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB Integer 0 violates the range [1, 1]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB Integer 0 violates the range [1, 1]
2 Halted 0 ms 0 KB -