Submission #606641

# Submission time Handle Problem Language Result Execution time Memory
606641 2022-07-26T07:34:05 Z radal Newspapers (CEOI21_newspapers) C++17
0 / 100
8 ms 12044 KB
#include <bits/stdc++.h>
#pragma GCC target("sse,sse2")
#pragma GCC optimize("unroll-loops,O3")
#define rep(i,l,r) for (int i = l; i < r; i++)
#define repr(i,r,l) for (int i = r; i >= l; i--)
#define X first
#define Y second
#define all(x) (x).begin() , (x).end()
#define pb push_back
#define endl '\n'
#define debug(x) cerr << #x << " : " << x << endl;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pll;
constexpr int N = 5e5+20,mod = 1e9+7,inf = 1e9+10,sq = 340;
inline int mkay(int a,int b){
    if (a+b >= mod) return a+b-mod;
    if (a+b < 0) return a+b+mod;
    return a+b;
}
 
inline int poww(int a,int k){
    if (k < 0) return 0;
    int z = 1;
    while (k){
        if (k&1) z = 1ll*z*a%mod;
        a = 1ll*a*a%mod;
        k /= 2;
    } 
    return z; 
}
vector<int> adj[N];
int main(){
    ios :: sync_with_stdio(0); cin.tie(0);
    int n,m;
    cin >> n >> m;
    if (n-1 < m){
        cout << "NO";
        return 0;
    }
    rep(i,1,n){
        int u,v;
        cin >> u >> v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    int mx = 0;
    rep(i,1,n+1) mx = max(mx,(int)adj[i].size());
    if (mx == n-1){
        cout << "YES" << endl << 2 << endl;
        rep(i,1,n+1){
            if ((int)adj[i].size() != n-1) continue;
            cout << i << ' ' << i << endl;
            return 0;
        }
    }
    if (mx == 2){
        cout << "YES" << endl;
        return 0;
    }
    cout << "NO" << endl;
    return 0;
} 
# Verdict Execution time Memory Grader output
1 Partially correct 6 ms 11988 KB Provide a successful but not optimal strategy.
2 Correct 6 ms 11988 KB Output is correct
3 Incorrect 6 ms 11988 KB Unexpected end of file - int32 expected
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 7 ms 12044 KB Provide a successful but not optimal strategy.
2 Correct 6 ms 11988 KB Output is correct
3 Correct 8 ms 11988 KB Output is correct
4 Incorrect 7 ms 11988 KB Unexpected end of file - int32 expected
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 6 ms 11988 KB Provide a successful but not optimal strategy.
2 Correct 6 ms 11988 KB Output is correct
3 Incorrect 6 ms 11988 KB Unexpected end of file - int32 expected
4 Halted 0 ms 0 KB -