Submission #991823
Source Code Expand
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctime> #include <iostream> #include <sstream> #include <functional> #include <map> #include <string> #include <cstring> #include <vector> #include <queue> #include <stack> #include <deque> #include <set> #include <list> #include <numeric> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<ll,ll> P; const double PI = 3.14159265358979323846; const double EPS = 1e-12; const ll INF = 1LL<<29; const ll mod = 1e9+7; #define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i)) #define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d)) #define all(v) (v).begin(), (v).end() #define pb(x) push_back(x) #define mp(x,y) make_pair((x),(y)) #define mset(m,v) memset((m),(v),sizeof(m)) #define chmin(X,Y) ((X)>(Y)?X=(Y),true:false) #define chmax(X,Y) ((X)<(Y)?X=(Y),true:false) #define fst first #define snd second #define UNIQUE(x) (x).erase(unique(all(x)),(x).end()) template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;} #define MAX_N 200000 struct UF { int par[MAX_N],rank[MAX_N]; void init(int n){ for(int i = 0; i < n; i++){ par[i] = i; rank[i] = 0; } } int find(int x){ if(par[x] == x){ return x; }else{ return par[x] = find(par[x]); } } void unite(int x, int y){ x = find(x); y = find(y); if(x == y) return; if(rank[x] < rank[y]){ par[x] = y; }else{ par[y] = par[x]; if(rank[x] == rank[y]) rank[y]++; } } bool same(int x, int y){ return find(x) == find(y); } }; int n, m; int l[N]; int main(){ mset(l, -1); cin>>n>>m; UF uf; uf.init(n); rep(i, n){ int k; cin>>k; rep(j, k){ int t; cin>>t; if(l[t]<0) l[t] = i; else uf.unite(l[t], i); } } bool ok = true; rep(i, n) if(!uf.same(0, i)) ok = false; cout<<(ok?"YES":"NO")<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Interpretation |
User | Lepton |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 2037 Byte |
Status | CE |
Compile Error
./Main.cpp:80:7: error: ‘N’ was not declared in this scope int l[N]; ^ ./Main.cpp: In function ‘int main()’: ./Main.cpp:82:7: error: ‘l’ was not declared in this scope mset(l, -1); ^ ./Main.cpp:33:27: note: in definition of macro ‘mset’ #define mset(m,v) memset((m),(v),sizeof(m)) ^