# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
145051 | 2019-08-18T14:43:58 Z | Mihnea | Alkemija (COCI18_alkemija) | C++14 | 224 ms | 12912 KB |
#include<iostream> #include<vector> using namespace std; int n,m,x,k,p,h,elem,r,R,nr; int F[100010],F1[100010],c[100010]; vector<int>L[100010]; struct reactie{ int C; /// nr elemente cerute int rez; /// nr elemente rezultate int neobtinute; vector<int>y; /// elementele rezultate }; reactie v[100010]; int main(){ cin>>n>>m; for(int i=1;i<=m;i++){ cin>>x; F[x]=1; } cin>>k; for(int i=1;i<=k;i++){ cin>>v[i].rez>>v[i].C; v[i].neobtinute=v[i].rez; for(int j=1;j<=v[i].rez;j++){ cin>>x; L[x].push_back(i); if(F[x]==1){ v[i].neobtinute--; if(v[i].neobtinute==0){ c[++h]=i; F1[i]=1; } } } for(int j=1;j<=v[i].C;j++){ cin>>x; v[i].y.push_back(x); } } p=1; while(p<=h){ r=c[p]; for(int i=0;i<v[r].y.size();i++){ elem=v[r].y[i]; if(F[elem]==0){ F[elem]=1; for(int j=0;j<L[elem].size();j++){ R=L[elem][j]; if(F1[R]==0){ v[R].neobtinute--; if(v[R].neobtinute==0){ c[++h]=R; F1[R]=1; } } } } } p++; } for(int i=1;i<=n;i++){ if(F[i]==1){ nr++; } } cout<<nr<<"\n"; for(int i=1;i<=n;i++){ if(F[i]==1){ 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 | 8 ms | 6648 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 | 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 | 54 ms | 8200 KB | Output is correct |
2 | Correct | 72 ms | 8824 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 133 ms | 10488 KB | Output is correct |
2 | Correct | 144 ms | 11000 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 189 ms | 12140 KB | Output is correct |
2 | Correct | 165 ms | 10980 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 224 ms | 12912 KB | Output is correct |
2 | Correct | 193 ms | 12216 KB | Output is correct |