Submission #991937


Source Code Expand

            #include <bits/stdc++.h>
            #include<iostream>
            #include<cstdio>
            #include<vector>
            #include<queue>
            #include<map>
            #include<cstring>
            #include<string>
            #include <math.h>
            #include<algorithm>
        //    #include <boost/multiprecision/cpp_int.hpp>
            #include<functional>
          #define int long long
            #define inf  1000000007
            #define pa pair<int,int>
    #define ll long long
            #define pal pair<ll,ll>
            #define ppa pair<int,pa>
            #define  mp make_pair
            #define  pb push_back
            #define EPS (1e-10)
            #define equals(a,b) (fabs((a)-(b))<EPS)
     
            using namespace std;
     
            class Point{
            	public:
            	double x,y;
            	Point(double x=0,double y=0):x(x),y(y) {}
            	Point operator + (Point p) {return Point(x+p.x,y+p.y);}
            	Point operator - (Point p) {return Point(x-p.x,y-p.y);}
            	Point operator * (double a) {return Point(x*a,y*a);}
            	Point operator / (double a) {return Point(x/a,y/a);}
            	double absv() {return sqrt(norm());}
            	double norm() {return x*x+y*y;}
            	bool operator < (const Point &p) const{
            		return x != p.x ? x<p.x: y<p.y;
            	}
            	bool operator == (const Point &p) const{
            		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
            	}
            };
            typedef Point Vector;
     
            struct Segment{
            Point p1,p2;
            };
     
        double hen(Vector a){
        if(fabs(a.x)<EPS && a.y>0) return acos(0);
        else if(fabs(a.x)<EPS && a.y<0) return 3*acos(0);
        else if(fabs(a.y)<EPS && a.x<0) return 2*acos(0);
        else if(fabs(a.y)<EPS && a.x>0) return 0.0;
        else if(a.y>0) return acos(a.x/a.absv());
        else return 2*acos(0)+acos(-a.x/a.absv());
     
        }
     
int gcd(int v,int b){
	if(v>b) return gcd(b,v);
	if(v==b) return b;
	if(b%v==0) return v;
	return gcd(v,b%v);
}
            double dot(Vector a,Vector b){
            	return a.x*b.x+a.y*b.y;
            }
            double cross(Vector a,Vector b){
            	return a.x*b.y-a.y*b.x;
            }
        
            //----------------kokomade tenpure------------

int par[200100],ranks[200100];     

void shoki(int n){
	for(int i=0;i<n;i++){
		par[i]=i;
		ranks[i]=0;
	}
}

int root(int x){
	return par[x]==x ? x : par[x]=root(par[x]);
}

bool same(int x,int y){
return root(x)==root(y);
}

void unite(int x,int y){
 x=root(x);
 y=root(y);
 if(x==y) return;
 if(ranks[x]<ranks[y]) par[x]=y;
 else {
	par[y]=x;
	if(ranks[x]==ranks[y]) ranks[x]=ranks[x]+1;
 }
}
    signed main(){
    	int n,m;
    	cin>>n>>m;
    	shoki(200010);
    	for(int i=1;i<=n;i++){
    		int k,l;
    		cin>>k;
    		for(int j=0;j<l;j++){
    			cin>>l;
    			unite(i,l+100003);
    			
    		}
    		
    		
    	}
    	
    	bool b=true;
    	
    	for(int i=1;i<=n-1;i++){
    		if(same(i,i+1)==false) b=false;
    	}
    	
    	if(b) cout<<"YES"<<endl;
    	else cout<<"NO"<<endl;

    //	printf("%.10f\n",ans);
    	return 0;
    }

Submission Info

Submission Time
Task C - Interpretation
User smiken
Language C++14 (GCC 5.4.1)
Score 0
Code Size 3371 Byte
Status WA
Exec Time 2102 ms
Memory 3328 KB

Judge Result

Set Name sample dataset1 dataset2
Score / Max Score 0 / 0 0 / 200 0 / 200
Status
WA × 2
AC × 6
WA × 6
AC × 14
WA × 10
TLE × 1
Set Name Test Cases
sample sample-01.txt, sample-02.txt
dataset1 sample-01.txt, sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt
dataset2 sample-01.txt, sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt, 02-09.txt, 02-10.txt, 02-11.txt, 02-12.txt, 02-13.txt
Case Name Status Exec Time Memory
01-01.txt AC 5 ms 3328 KB
01-02.txt AC 6 ms 3328 KB
01-03.txt WA 6 ms 3328 KB
01-04.txt AC 6 ms 3328 KB
01-05.txt WA 6 ms 3328 KB
01-06.txt AC 8 ms 3328 KB
01-07.txt WA 6 ms 3328 KB
01-08.txt WA 6 ms 3328 KB
01-09.txt AC 6 ms 3328 KB
01-10.txt AC 6 ms 3328 KB
02-01.txt AC 1816 ms 3328 KB
02-02.txt WA 42 ms 3328 KB
02-03.txt AC 1575 ms 3328 KB
02-04.txt AC 44 ms 3328 KB
02-05.txt AC 43 ms 3328 KB
02-06.txt TLE 2102 ms 3328 KB
02-07.txt AC 45 ms 3328 KB
02-08.txt WA 36 ms 3328 KB
02-09.txt AC 50 ms 3328 KB
02-10.txt AC 41 ms 3328 KB
02-11.txt WA 42 ms 3328 KB
02-12.txt WA 40 ms 3328 KB
02-13.txt AC 40 ms 3328 KB
sample-01.txt WA 6 ms 3328 KB
sample-02.txt WA 6 ms 3328 KB