Submission #1336576
Source Code Expand
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
using namespace std;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;
const int N = 1e5 + 10;
vector<int> a[N];
int f[N];
int find(int x) {
if (f[x] != f[f[x]]) f[x] = find(f[x]);
return f[x];
}
int main() {
int n, m;
scanf("%d%d", &n, &m);
for (int i = 0; i < n; ++i) {
int len;
scanf("%d", &len);
while (len--) {
int x;
scanf("%d", &x);
--x;
a[x].push_back(i);
}
f[i] = i;
}
for (int i = 0; i < m; ++i) {
for (int j = 1; j < a[i].size(); ++j) {
int x = a[i][j - 1], y = a[i][j];
int rx = find(x), ry = find(y);
if (rx != ry) {
f[ry] = rx;
}
}
}
int ret = 0;
for (int i = 0; i < n; ++i) {
if (find(i) == i) ++ret;
}
puts(ret == 1 ? "YES" : "NO");
return 0;
}
Submission Info
Submission Time |
|
Task |
C - Interpretation |
User |
cuiaoxiang |
Language |
C++14 (GCC 5.4.1) |
Score |
400 |
Code Size |
1687 Byte |
Status |
AC |
Exec Time |
26 ms |
Memory |
4608 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:52:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &n, &m);
^
./Main.cpp:55:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &len);
^
./Main.cpp:58:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &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, sample-01.txt, sample-02.txt |
Case Name |
Status |
Exec Time |
Memory |
01-01.txt |
AC |
2 ms |
2560 KB |
01-02.txt |
AC |
2 ms |
2560 KB |
01-03.txt |
AC |
3 ms |
2560 KB |
01-04.txt |
AC |
2 ms |
2560 KB |
01-05.txt |
AC |
3 ms |
2560 KB |
01-06.txt |
AC |
3 ms |
2560 KB |
01-07.txt |
AC |
2 ms |
2560 KB |
01-08.txt |
AC |
3 ms |
2560 KB |
01-09.txt |
AC |
2 ms |
2560 KB |
01-10.txt |
AC |
2 ms |
2560 KB |
02-01.txt |
AC |
21 ms |
4608 KB |
02-02.txt |
AC |
20 ms |
3584 KB |
02-03.txt |
AC |
22 ms |
3968 KB |
02-04.txt |
AC |
26 ms |
4224 KB |
02-05.txt |
AC |
24 ms |
3712 KB |
02-06.txt |
AC |
26 ms |
4224 KB |
02-07.txt |
AC |
25 ms |
3712 KB |
02-08.txt |
AC |
19 ms |
3556 KB |
02-09.txt |
AC |
21 ms |
3452 KB |
02-10.txt |
AC |
19 ms |
4480 KB |
02-11.txt |
AC |
19 ms |
4480 KB |
02-12.txt |
AC |
19 ms |
4480 KB |
02-13.txt |
AC |
20 ms |
4480 KB |
sample-01.txt |
AC |
2 ms |
2560 KB |
sample-02.txt |
AC |
2 ms |
2560 KB |