Submission #991940
Source Code Expand
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <deque>
#include <string>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#define pb push_back
#define pbk pop_back
#define mp make_pair
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define foreach(i, a) for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
#define len(a) ((int) (a).size())
#ifdef CUTEBMAING
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif
using namespace std;
typedef long long int64;
typedef long double ld;
typedef unsigned long long lint;
const int inf = (1 << 30) - 1;
const int64 linf = (1ll << 62) - 1;
const int N = 1e6 + 100;
int n, m;
vector<int> a[N];
vector<int> g[N];
bool used[N];
void dfs(int v) {
if (used[v]) {
return ;
}
used[v] = true;
for (int i : g[v]) {
dfs(i);
}
}
int main() {
#ifdef XCODE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
cin >> n >> m;
for (int i = 0; i < n; i++) {
int len; scanf("%d", &len);
for (int j = 0; j < len; j++) {
int x; scanf("%d", &x), x--;
a[x].pb(i);
}
}
for (int i = 0; i < m; i++) {
for (int j = 0; j < len(a[i]) - 1; j++) {
g[a[i][j]].pb(a[i][j + 1]);
g[a[i][j + 1]].pb(a[i][j]);
}
}
dfs(0);
for (int i = 0; i < n; i++) {
if (!used[i]) {
puts("NO");
return 0;
}
}
puts("YES");
return 0;
}
Submission Info
Submission Time
2016-11-26 12:43:17+0900
Task
C - Interpretation
User
darinflar
Language
C++14 (GCC 5.4.1)
Score
400
Code Size
1823 Byte
Status
AC
Exec Time
89 ms
Memory
53880 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:70:35: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
int len; scanf("%d", &len);
^
./Main.cpp:72:40: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
int x; scanf("%d", &x), x--;
^
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
51 ms
47104 KB
01-02.txt
AC
52 ms
47104 KB
01-03.txt
AC
52 ms
47104 KB
01-04.txt
AC
51 ms
47232 KB
01-05.txt
AC
52 ms
47104 KB
01-06.txt
AC
52 ms
47104 KB
01-07.txt
AC
52 ms
47104 KB
01-08.txt
AC
52 ms
47104 KB
01-09.txt
AC
51 ms
47104 KB
01-10.txt
AC
52 ms
47232 KB
02-01.txt
AC
76 ms
49792 KB
02-02.txt
AC
89 ms
51712 KB
02-03.txt
AC
79 ms
49664 KB
02-04.txt
AC
88 ms
50304 KB
02-05.txt
AC
89 ms
51200 KB
02-06.txt
AC
88 ms
50304 KB
02-07.txt
AC
89 ms
50816 KB
02-08.txt
AC
81 ms
52324 KB
02-09.txt
AC
86 ms
53880 KB
02-10.txt
AC
77 ms
52092 KB
02-11.txt
AC
77 ms
52092 KB
02-12.txt
AC
77 ms
50816 KB
02-13.txt
AC
78 ms
50816 KB
sample-01.txt
AC
51 ms
47232 KB
sample-02.txt
AC
51 ms
47104 KB