Submission #991824
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))
// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD
// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;
int data[125252];
int init(){
REP(i,125252)data[i]=-1;
}
int root(int x){
return data[x]<0?x:data[x]=root(data[x]);
}
void unite(int a,int b){
a=root(a);b=root(b);
if(a!=b){
if(data[a]>data[b])swap(a,b);
data[a] += data[b];
data[b] = a;
}
}
int size(int x){
return -data[root(x)];
}
int n,m;
vi langs[125252];
int main(){
init();
scanf("%d%d",&n,&m);
REP(i,n){
int k;
scanf("%d",&k);
REP(j,k){
int l;
scanf("%d",&l);
--l;
langs[l].push_back(i);
}
}
REP(i,m){
REP(j,langs[i].size()-1){
unite(langs[i][j],langs[i][j+1]);
}
}
puts(size(0)==n?"YES":"NO");
return 0;
}
Submission Info
Submission Time |
|
Task |
C - Interpretation |
User |
rickytheta |
Language |
C++14 (GCC 5.4.1) |
Score |
400 |
Code Size |
1572 Byte |
Status |
AC |
Exec Time |
30 ms |
Memory |
5632 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:58:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&n,&m);
^
./Main.cpp:61:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&k);
^
./Main.cpp:64:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&l);
^
Judge Result
Set Name |
sample |
dataset1 |
dataset2 |
Score / Max Score |
0 / 0 |
200 / 200 |
200 / 200 |
Status |
|
|
|
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 |
3712 KB |
01-02.txt |
AC |
6 ms |
3712 KB |
01-03.txt |
AC |
6 ms |
3712 KB |
01-04.txt |
AC |
6 ms |
3712 KB |
01-05.txt |
AC |
6 ms |
3712 KB |
01-06.txt |
AC |
6 ms |
3712 KB |
01-07.txt |
AC |
6 ms |
3712 KB |
01-08.txt |
AC |
6 ms |
3712 KB |
01-09.txt |
AC |
6 ms |
3712 KB |
01-10.txt |
AC |
6 ms |
3712 KB |
02-01.txt |
AC |
25 ms |
5632 KB |
02-02.txt |
AC |
23 ms |
4224 KB |
02-03.txt |
AC |
25 ms |
5120 KB |
02-04.txt |
AC |
29 ms |
4992 KB |
02-05.txt |
AC |
27 ms |
4480 KB |
02-06.txt |
AC |
30 ms |
4992 KB |
02-07.txt |
AC |
28 ms |
4480 KB |
02-08.txt |
AC |
22 ms |
4224 KB |
02-09.txt |
AC |
24 ms |
4348 KB |
02-10.txt |
AC |
23 ms |
5504 KB |
02-11.txt |
AC |
23 ms |
5504 KB |
02-12.txt |
AC |
23 ms |
5376 KB |
02-13.txt |
AC |
23 ms |
5376 KB |
sample-01.txt |
AC |
5 ms |
3712 KB |
sample-02.txt |
AC |
5 ms |
3712 KB |