Submission #1185239

#TimeUsernameProblemLanguageResultExecution timeMemory
1185239cpdreamerNewspapers (CEOI21_newspapers)C++20
4 / 100
1 ms328 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair
#define F first
#define all(v) v.begin(),v.end()
#define V vector
#define pb push_back
#define S second
void file() {
    freopen("input.txt.txt", "r", stdin);
    freopen("output.txt.txt", "w", stdout);
}

V<int>binary_rep(int n){
    V<int>vp;
    for(int i=0;i<30;i++){
        if(((1<<i)&n)!=0)
            vp.pb(1);
        else
            vp.pb(0);
    }
    return vp;
}
void solve() {
    int n;
    cin>>n;
    int m;
    cin>>m;
    V<int>adj[n+1];
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    if(m!=n-1){
        cout<<"NO"<<endl;
        return;
    }
    for(int i=1;i<=n;i++){
        if((int)adj[i].size()>=3){
            cout<<"NO"<<endl;
            return;
        }
    }
    cout<<"YES"<<endl;
    cout<<1<<endl;
    cout<<1<<endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //file();
    solve();
}

Compilation message (stderr)

newspapers.cpp: In function 'void file()':
newspapers.cpp:11:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     freopen("input.txt.txt", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
newspapers.cpp:12:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     freopen("output.txt.txt", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...