Submission #993647
Source Code Expand
#include <iostream> #include <vector> #include <stdlib.h> #include <math.h> #include <algorithm> #include <queue> using namespace std; bool ok[100001][1000001]; int main() { int l[100000]; bool reached[100001]; int n, m; cin >> n >> m; int k; for (int i = 0; i <= m; i++) { reached[i] = true; } for (int i = 0; i < n; i++) { cin >> k; for (int x = 0; x < k; x++) { cin >> l[x]; reached[l[x]] = false; } // sort(l, l + k); for (int dist = 0; dist < k-1; dist++) { for (int sorce = dist + 1; sorce < k; sorce++) { int x = l[dist]; int y = l[sorce]; ok[x][y] = true; ok[y][x] = true; } } } queue<int> queue; for (int i = 1; i <= m; i++) { if (reached[i] == false) { queue.push(i); reached[i] = true; break; } } while (!queue.empty()) { int target; target = queue.front(); queue.pop(); for (int i = 1; i <= m; i++) { if (target == i) { continue; } if (ok[target][i] == false) { continue; } if (reached[i] == true) { //ignore } else { queue.push(i); reached[i] = true; } } } for (int i = 1; i <= m; i++) { if (reached[i] == false) { cout << "NO" << endl; return 0; } } cout << "YES" << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Where's Snuke? |
User | ysakasin |
Language | C++14 (Clang 3.8.0) |
Score | 0 |
Code Size | 1326 Byte |
Status | RE |
Exec Time | 1 ms |
Memory | 128 KB |
Judge Result
Set Name | sample | all | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 100 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
sample | sample-01.txt, sample-02.txt |
all | 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 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | RE | 1 ms | 128 KB |
01-02.txt | RE | 1 ms | 128 KB |
01-03.txt | RE | 1 ms | 128 KB |
01-04.txt | RE | 1 ms | 128 KB |
01-05.txt | RE | 1 ms | 128 KB |
01-06.txt | RE | 1 ms | 128 KB |
01-07.txt | RE | 1 ms | 128 KB |
sample-01.txt | RE | 1 ms | 128 KB |
sample-02.txt | RE | 1 ms | 128 KB |