Submission #811821

#TimeUsernameProblemLanguageResultExecution timeMemory
811821t6twotwoNewspapers (CEOI21_newspapers)C++17
4 / 100
1 ms212 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define FFOR(i,a,b,c) for(int i=(a);(c)>0?i<=(b):i>=(b);i+=(c)) #define FOOR(i,a,b) FFOR(i,a,b-1,1) #define ROOF(i,a,b) FFOR(i,b-1,a,-1) #define FOR(i,n) FOOR(i,0,n) #define ROF(i,n) ROOF(i,0,n) #define FORR(x,v) for(auto &x:v) #define all(v) (v).begin(),(v).end() #define lla(v) (v).rbegin(),(v).rend() #define sz(v) (int)((v).size()) #define vc vector #define pb push_back #define ppb pop_back #define bk back() #define fr front() #define pp pop() #define eb emplace_back #define lb lower_bound #define ub upper_bound #define bg begin() #define en end() #define em empty() #define f first #define s second int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N,M; cin>>N>>M; vector<int> p(N); iota(all(p),0); function<int(int)> find=[&](int x){ return x==p[x]?x:p[x]=find(p[x]); }; bool tree=1; FOR(i,M){ int x,y; cin>>x>>y; x--,y--; if(find(x)==find(y)){ tree=0; }else{ p[p[x]]=p[y]; } } if(tree) cout <<"YES\n1\n1"; else cout<<"NO"; return 6/22; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...