Submission #145079

# Submission time Handle Problem Language Result Execution time Memory
145079 2019-08-18T17:22:16 Z mihaican Alkemija (COCI18_alkemija) C++14
80 / 80
197 ms 12592 KB
/*#include <iostream>

using namespace std;
int x,r1,r2;
int main(){
    cin>>x;
     x/=52;
    for(int i=100;i>0;i--)
        if((x-7*i)%21==0&&x-7*i>0){
            r1=i,r2=(x-7*i)/21;
            break;
        }
    cout<<r1<<" "<<r2;

    return 0;
}
*/
#include <iostream>
#include <deque>
#include <vector>

using namespace std;
struct int2 {
    int necesare;
    int necunoscute;
    int rezultate;
    vector<int> v2;
}v[100010];
int id,n,m,x,k,c,n2,f[100010],f2[100010];;
deque<int>coada;
vector<int>a[100010];
int main(){
    cin>>n>>m;
    for(int i=1;i<=m;i++)
        cin>>x,f[x]=1,n2++;
    cin>>k;
    for(int i=1;i<=k;i++){
        cin>>v[i].necesare>>v[i].rezultate;
        v[i].necunoscute = v[i].necesare;
        for(int j=1;j<=v[i].necesare;j++){
            cin>>x;
            a[x].push_back(i);
            if (f[x]==1){
                v[i].necunoscute--;
            if (v[i].necunoscute==0)
                    coada.push_back(i),f2[i]=1;
            }
        }
    for(int j=1;j<=v[i].rezultate;j++)
        cin>>x,v[i].v2.push_back(x);
    }
    while(!coada.empty()){
        int curent=coada.front();
        coada.pop_front();
        for(int i=0;i<v[curent].v2.size();i++){
            c=v[curent].v2[i];
            if (f[c]==0){
                for(int j=0;j<a[c].size();j++){
                    id=a[c][j];
                    if (f2[id]==0){
                        v[id].necunoscute--;
                        if(v[id].necunoscute==0)
                            f2[id]=1,coada.push_back(id);

                        }
                }
                f[c]=1;
                n2++;
            }
    }
    }

    cout<<n2<<endl;
    for (int i=1;i<=100000;i++)
        if (f[i])
            cout<<i<<" ";
}

Compilation message

alkemija.cpp: In function 'int main()':
alkemija.cpp:55:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i=0;i<v[curent].v2.size();i++){
                     ~^~~~~~~~~~~~~~~~~~~~
alkemija.cpp:58:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 for(int j=0;j<a[c].size();j++){
                             ~^~~~~~~~~~~~
# 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 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 8 ms 6648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 55 ms 8216 KB Output is correct
2 Correct 76 ms 8780 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 136 ms 10532 KB Output is correct
2 Correct 147 ms 10844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 177 ms 11952 KB Output is correct
2 Correct 160 ms 11128 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 197 ms 12592 KB Output is correct
2 Correct 186 ms 12024 KB Output is correct