Submission #2835354
Source Code Expand
#include <bits/stdc++.h> using namespace std; #define int long long const double PI = 3.14159265358979323846; typedef vector<int> vint; typedef pair<int, int> pint; int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; int N, M; int K[110000]; vint L[110000], G[220000]; bool visited[220000]; void dfs(int x) { visited[x] = true; for (int i = 0; i < G[x].size(); i++) { if (!visited[G[x][i]]) dfs(G[x][i]); } } signed main() { cin >> N >> M; for (int i = 0; i < N; i++) { cin >> K[i]; L[i].resize(K[i]); for (int j = 0; j < K[i]; j++) { cin >> L[i][j]; G[i].push_back(110000 + L[i][j]); G[110000 + L[i][j]].push_back(i); } } dfs(0); for (int i = 0; i < N; i++) { if (!visited[i]) { cout << "NO" << endl; return 0; } } cout << "YES" << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Interpretation |
User | packer_jp |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 986 Byte |
Status | AC |
Exec Time | 71 ms |
Memory | 16000 KB |
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 | 4 ms | 8192 KB |
01-02.txt | AC | 4 ms | 8320 KB |
01-03.txt | AC | 4 ms | 8320 KB |
01-04.txt | AC | 4 ms | 8320 KB |
01-05.txt | AC | 4 ms | 8320 KB |
01-06.txt | AC | 4 ms | 8320 KB |
01-07.txt | AC | 4 ms | 8320 KB |
01-08.txt | AC | 4 ms | 8320 KB |
01-09.txt | AC | 4 ms | 8320 KB |
01-10.txt | AC | 4 ms | 8320 KB |
02-01.txt | AC | 51 ms | 12800 KB |
02-02.txt | AC | 59 ms | 16000 KB |
02-03.txt | AC | 51 ms | 12672 KB |
02-04.txt | AC | 71 ms | 13952 KB |
02-05.txt | AC | 65 ms | 15360 KB |
02-06.txt | AC | 69 ms | 13952 KB |
02-07.txt | AC | 71 ms | 15744 KB |
02-08.txt | AC | 49 ms | 15856 KB |
02-09.txt | AC | 62 ms | 15860 KB |
02-10.txt | AC | 51 ms | 14324 KB |
02-11.txt | AC | 52 ms | 14324 KB |
02-12.txt | AC | 51 ms | 14208 KB |
02-13.txt | AC | 51 ms | 14208 KB |
sample-01.txt | AC | 4 ms | 8192 KB |
sample-02.txt | AC | 4 ms | 8192 KB |