# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
142623 | 2019-08-10T05:17:31 Z | KCSC | Alkemija (COCI18_alkemija) | C++14 | 188 ms | 10656 KB |
#include <bits/stdc++.h> using namespace std; const int DIM = 100005; deque<int> que; vector<int> lef[DIM], rig[DIM]; bool oki[DIM]; int cnt[DIM]; int main(void) { #ifdef HOME freopen("alkemija.in", "r", stdin); freopen("alkemija.out", "w", stdout); #endif int n, m; cin >> n >> m; for (int i = 1; i <= m; ++i) { int x; cin >> x; que.push_back(x); } int k; cin >> k; for (int i = 1; i <= k; ++i) { int l, r; cin >> l >> r; for (int j = 1; j <= l; ++j) { int x; cin >> x; lef[x].push_back(i); } for (int j = 1; j <= r; ++j) { int x; cin >> x; rig[i].push_back(x); } } for (; que.size(); que.pop_front()) { int x = que.front(); if (oki[x]) continue; oki[x] = true; for (int y : lef[x]) if (++cnt[y] == lef[y].size()) for (int z : rig[y]) que.push_back(z); } int nr = 0; for (int i = 1; i <= n; ++i) nr += oki[i]; cout << nr << endl; for (int i = 1; i <= n; ++i) if (oki[i]) cout << i << " "; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 5112 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 4984 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 4988 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 4984 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 7 ms | 5112 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 5112 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 53 ms | 6524 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 131 ms | 8692 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 169 ms | 10092 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 188 ms | 10656 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |