# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
144784 | 2019-08-17T17:40:43 Z | RaresRosca | Alkemija (COCI18_alkemija) | C++14 | 206 ms | 12588 KB |
#include <iostream> #include <deque> #include <vector> using namespace std; int n,m,i,j,x,f[100010],f1[100010],k,ec,reac,sol; deque<int> q; vector<int> D[100010]; struct reactie{ int L; int R; int N; vector<int> Y; }; reactie v[100010]; int main(){ cin>>n>>m; for(i=1;i<=m;i++){ cin>>x; f[x]=1; } cin>>k; for(i=1;i<=k;i++){ cin>>v[i].L>>v[i].R; v[i].N=v[i].L; for(j=1;j<=v[i].L;j++){ cin>>x; D[x].push_back(i); if(f[x]==1){ v[i].N--; if(v[i].N==0){ q.push_back(i); f1[i]=1; } } } for(j=1;j<=v[i].R;j++){ cin>>x; v[i].Y.push_back(x); } } while(!q.empty()){ x=q.front(); q.pop_front(); for(i=0;i<v[x].Y.size();i++){ ec=v[x].Y[i]; if(f[ec]==0){ f[ec]=1; for(j=0;j<D[ec].size();j++){ reac=D[ec][j]; if(f1[reac]==0){ v[reac].N--; if(v[reac].N==0){ q.push_back(reac); f1[reac]=1; } } } } } } for(i=1;i<=n;i++) if(f[i]==1) sol++; cout<<sol<<"\n"; for(i=1;i<=n;i++) if(f[i]==1) cout<<i<<" "; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 6648 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 6524 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 | 6648 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 6648 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 6648 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 55 ms | 8240 KB | Output is correct |
2 | Correct | 74 ms | 8824 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 138 ms | 10364 KB | Output is correct |
2 | Correct | 147 ms | 10872 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 181 ms | 11848 KB | Output is correct |
2 | Correct | 161 ms | 11144 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 206 ms | 12588 KB | Output is correct |
2 | Correct | 188 ms | 12116 KB | Output is correct |