Submission #1678174
Source Code Expand
#include <iostream> #include <iomanip> #include <algorithm> #include <string> #include <cstdio> #include <cmath> #include <cstdlib> #include <cstring> #include <vector> #include <list> #include <map> #include <set> #include <queue> #include <stack> #define INF (int)1e09 using std::cin; using std::cout; using std::endl; using std::setprecision; using std::fixed; using std::pair; using std::make_pair; using std::min; using std::max; using std::string; using std::vector; using std::list; using std::map; using std::set; // insert erase find count using std::queue; using std::priority_queue; using std::stack; template <typename T> using Vec = vector<T>; // c++11 typedef pair<int, int> PII; typedef pair<int, pair<int, int> > PIII; int main(void) { int n; int m; cin >> n >> m; Vec<Vec<int> > pers(n); Vec<Vec<int> > lang(m); for (int i = 0; i < n; i++) { int times; cin >> times; for (int j = 0; j < times; j++) { int l; cin >> l; l--; pers[i].push_back(l); lang[l].push_back(i); } } Vec<bool> check(n, false); int init = lang[0].size(); for (int i = 0; i < init; i++) { check[lang[0][i]] = true; } while (1) { bool change = false; for (int i = 1; i < m; i++) { if (lang[i].size() == 0) { continue; } int len = lang[i].size(); bool exist = false; for (int j = 0; j < len; j++) { if (check[lang[i][j]] == true) { exist = true; } } if (exist == true) { for (int j = 0; j < len; j++) { if (check[lang[i][j]] == false) { cout << i << " " << j << endl; cout << lang[i][j] << endl; check[lang[i][j]] = true; change = true; } } } } if (change == false) { break; } } bool ans = true; for (int i = 0; i < n; i++) { if (check[i] == false) { ans = false; break; } } if (ans == true) { cout << "YES" << endl; } else { cout << "NO" << endl; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Interpretation |
User | naobird |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 2486 Byte |
Status | WA |
Exec Time | 378 ms |
Memory | 8440 KB |
Judge Result
Set Name | sample | dataset1 | dataset2 | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 200 | 0 / 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 | 1 ms | 256 KB |
01-02.txt | WA | 2 ms | 256 KB |
01-03.txt | AC | 2 ms | 384 KB |
01-04.txt | WA | 3 ms | 256 KB |
01-05.txt | WA | 4 ms | 256 KB |
01-06.txt | WA | 2 ms | 256 KB |
01-07.txt | WA | 2 ms | 256 KB |
01-08.txt | AC | 2 ms | 256 KB |
01-09.txt | WA | 4 ms | 256 KB |
01-10.txt | WA | 2 ms | 384 KB |
02-01.txt | WA | 46 ms | 5376 KB |
02-02.txt | WA | 372 ms | 7296 KB |
02-03.txt | WA | 79 ms | 3840 KB |
02-04.txt | WA | 349 ms | 7808 KB |
02-05.txt | WA | 325 ms | 6656 KB |
02-06.txt | AC | 55 ms | 7040 KB |
02-07.txt | WA | 378 ms | 7296 KB |
02-08.txt | AC | 40 ms | 6136 KB |
02-09.txt | WA | 55 ms | 8440 KB |
02-10.txt | WA | 210 ms | 7032 KB |
02-11.txt | WA | 212 ms | 7032 KB |
02-12.txt | WA | 211 ms | 6784 KB |
02-13.txt | WA | 212 ms | 6784 KB |
sample-01.txt | WA | 1 ms | 256 KB |
sample-02.txt | AC | 1 ms | 256 KB |