Submission #991924
Source Code Expand
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
int main() {
int N, M; scanf("%d%d", &N, &M);
vector<vector<int>> graph(N + M);
for(int i = 0; i < N; ++i) {
int K; scanf("%d", &K);
for(int j = 0; j < K; ++j) {
int L; scanf("%d", &L); --L;
graph[i].push_back(N+L);
graph[N+L].push_back(i);
}
}
vector<char> vis(N + M, false);
function<void(int)> visit = [&](int v) {
if(vis[v]) return;
vis[v] = true;
for(int w : graph[v]) {
visit(w);
}
};
visit(0);
for(int i = 0; i < N; ++i) {
if(!vis[i]) {
printf("NO\n");
return 0;
}
}
printf("YES\n");
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Interpretation |
| User | qnighy |
| Language | C++14 (GCC 5.4.1) |
| Score | 400 |
| Code Size | 735 Byte |
| Status | AC |
| Exec Time | 41 ms |
| Memory | 8568 KiB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:8:34: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
int N, M; scanf("%d%d", &N, &M);
^
./Main.cpp:11:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
int K; scanf("%d", &K);
^
./Main.cpp:13:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
int L; scanf("%d", &L); --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 | 2 ms | 256 KiB |
| 01-02.txt | AC | 3 ms | 256 KiB |
| 01-03.txt | AC | 3 ms | 384 KiB |
| 01-04.txt | AC | 3 ms | 256 KiB |
| 01-05.txt | AC | 3 ms | 256 KiB |
| 01-06.txt | AC | 3 ms | 256 KiB |
| 01-07.txt | AC | 3 ms | 256 KiB |
| 01-08.txt | AC | 3 ms | 256 KiB |
| 01-09.txt | AC | 3 ms | 256 KiB |
| 01-10.txt | AC | 3 ms | 256 KiB |
| 02-01.txt | AC | 30 ms | 5888 KiB |
| 02-02.txt | AC | 34 ms | 6272 KiB |
| 02-03.txt | AC | 30 ms | 4608 KiB |
| 02-04.txt | AC | 41 ms | 7168 KiB |
| 02-05.txt | AC | 37 ms | 6272 KiB |
| 02-06.txt | AC | 41 ms | 7168 KiB |
| 02-07.txt | AC | 37 ms | 6272 KiB |
| 02-08.txt | AC | 29 ms | 6136 KiB |
| 02-09.txt | AC | 35 ms | 8568 KiB |
| 02-10.txt | AC | 28 ms | 6136 KiB |
| 02-11.txt | AC | 28 ms | 6136 KiB |
| 02-12.txt | AC | 29 ms | 6144 KiB |
| 02-13.txt | AC | 29 ms | 6144 KiB |
| sample-01.txt | AC | 2 ms | 256 KiB |
| sample-02.txt | AC | 2 ms | 256 KiB |