# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
143137 | 2019-08-13T08:15:10 Z | mariusnicoli | Alkemija (COCI18_alkemija) | C++14 | 199 ms | 12144 KB |
/** **/ #include <iostream> #include <deque> #include <vector> #include <bitset> using namespace std; struct reactie { int L; int R; int necunoscute; vector<int> Y; }; reactie e[100010]; deque<int> coada; vector<int> Lista[100010]; int n, m, i, v, k, j, x, nod, ec, reactie, sol; bitset<100010> f, viz; int main () { cin>>n>>m; for (i=1;i<=m;i++) { cin>>v; f[v] = 1; } cin>>k; for (i=1;i<=k;i++) { cin>>e[i].L>>e[i].R; e[i].necunoscute = e[i].L; for (j=1;j<=e[i].L;j++) { cin>>x; Lista[x].push_back(i); if (f[x] == 1) { e[i].necunoscute--; if (e[i].necunoscute == 0) { coada.push_back(i); viz[i] = 1; } } } for (j=1;j<=e[i].R;j++) { cin>>x; e[i].Y.push_back(x); } } while (!coada.empty()) { nod = coada.front(); coada.pop_front(); /// nod este o lista cu toate reactieele marcate for (i=0;i<e[nod].Y.size();i++) { ec = e[nod].Y[i]; if (f[ec] == 0) { f[ec] = 1; for (j=0;j<Lista[ec].size();j++) { reactie = Lista[ec][j]; if (viz[reactie] == 0) { e[reactie].necunoscute--; if (e[reactie].necunoscute == 0) { coada.push_back(reactie); viz[reactie] = 1; } } } } } } for (i=1;i<=100000;i++) if (f[i] == 1) sol++; cout<<sol<<"\n"; for (i=1;i<=100000;i++) if (f[i] == 1) cout<<i<<" "; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 6520 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 6520 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 6520 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 6520 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 6588 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 6648 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 54 ms | 7972 KB | Output is correct |
2 | Correct | 73 ms | 8580 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 132 ms | 10104 KB | Output is correct |
2 | Correct | 162 ms | 10628 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 190 ms | 11612 KB | Output is correct |
2 | Correct | 160 ms | 10872 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 199 ms | 12144 KB | Output is correct |
2 | Correct | 187 ms | 11484 KB | Output is correct |