# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
145117 | 2019-08-18T19:51:22 Z | Radugnn | Alkemija (COCI18_alkemija) | C++14 | 195 ms | 12028 KB |
#include <iostream> #include <deque> #include <vector> using namespace std; struct reactie{ int L; int R; int nec; vector<int> REZ; }e[100010]; deque<int> q; vector<int> Lista[100010]; int N,M,x,C[100010],viz[100010],K,i,j,ec,sol,react,el; int main(){ cin>>N>>M; for(i=1;i<=M;i++){ cin>>x; C[x]=1; } cin>>K; for(i=1;i<=K;i++){ cin>>e[i].L>>e[i].R; e[i].nec=e[i].L; for (j=1;j<=e[i].L;j++) { cin>>x; Lista[x].push_back(i); if (C[x]) { e[i].nec--; if (e[i].nec==0) { q.push_back(i); viz[i] = 1; } } } for (j=1;j<=e[i].R;j++) { cin>>x; e[i].REZ.push_back(x); } } while (!q.empty()) { el=q.front(); q.pop_front(); for (i=0;i<e[el].REZ.size();i++) { ec = e[el].REZ[i]; if (C[ec]==0) { C[ec]=1; for (j=0;j<Lista[ec].size();j++) { react=Lista[ec][j]; if (viz[react]==0) { e[react].nec--; if (e[react].nec==0) { q.push_back(react); viz[react]=1; } } } } } } for (i=1;i<=N;i++) if (C[i]) sol++; cout<<sol<<"\n"; for (i=1;i<=N;i++) if (C[i]) cout<<i<<" "; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 6648 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 | 7 ms | 6520 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 | 66 ms | 7872 KB | Output is correct |
2 | Correct | 77 ms | 8696 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 149 ms | 9720 KB | Output is correct |
2 | Correct | 142 ms | 10872 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 172 ms | 11360 KB | Output is correct |
2 | Correct | 158 ms | 11360 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 195 ms | 12008 KB | Output is correct |
2 | Correct | 179 ms | 12028 KB | Output is correct |