Submission #992593
Source Code Expand
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#define F first
#define S second
using namespace std;
int p[111111];
void init(int x){
for(int i = 0; i <= x; i++) p[i] = i;
}
int find(int x){
return p[x]==x?x:p[x]=find(p[x]);
}
bool same(int x,int y){
return find(x) == find(y);
}
void merge(int x,int y){
p[find(x)] = find(y);
}
int n,m;
int k[111111];
vector<int> l[111111];
int main(void){
scanf("%d %d",&n,&m);
init(m);
for(int i = 0; i < n; i++){
scanf("%d",k+i);
for(int j = 0; j < k[i]; j++){
int ll;
scanf("%d",&ll);
l[i].push_back(ll);
if(j){
merge(l[i][0],l[i][j]);
}
}
}
bool f = true;
for(int i = 1; i < n; i++){
if(!same(l[0][0],l[i][0])) f = false;
}
if(f) puts("YES");
else puts("NO");
}
Submission Info
Submission Time |
|
Task |
C - Interpretation |
User |
gotto |
Language |
C++14 (GCC 5.4.1) |
Score |
400 |
Code Size |
976 Byte |
Status |
AC |
Exec Time |
30 ms |
Memory |
6784 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:36:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d",&n,&m);
^
./Main.cpp:41:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",k+i);
^
./Main.cpp:44:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&ll);
^
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 |
2816 KB |
01-02.txt |
AC |
5 ms |
2816 KB |
01-03.txt |
AC |
5 ms |
2944 KB |
01-04.txt |
AC |
5 ms |
2944 KB |
01-05.txt |
AC |
5 ms |
2816 KB |
01-06.txt |
AC |
5 ms |
2816 KB |
01-07.txt |
AC |
5 ms |
2816 KB |
01-08.txt |
AC |
5 ms |
2816 KB |
01-09.txt |
AC |
5 ms |
2816 KB |
01-10.txt |
AC |
5 ms |
2944 KB |
02-01.txt |
AC |
21 ms |
3840 KB |
02-02.txt |
AC |
29 ms |
6272 KB |
02-03.txt |
AC |
23 ms |
3712 KB |
02-04.txt |
AC |
28 ms |
5248 KB |
02-05.txt |
AC |
29 ms |
5760 KB |
02-06.txt |
AC |
28 ms |
5248 KB |
02-07.txt |
AC |
29 ms |
6016 KB |
02-08.txt |
AC |
28 ms |
6400 KB |
02-09.txt |
AC |
30 ms |
6784 KB |
02-10.txt |
AC |
23 ms |
4992 KB |
02-11.txt |
AC |
23 ms |
4988 KB |
02-12.txt |
AC |
23 ms |
4992 KB |
02-13.txt |
AC |
23 ms |
4992 KB |
sample-01.txt |
AC |
5 ms |
2816 KB |
sample-02.txt |
AC |
5 ms |
2816 KB |