This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int M = 1000;
int main()
{
int n;
cin>>n;
bitset<1000> inh[M],tem;
map<string,int> ind;
for (int wht=0;wht<n;wht++)
{
string s;
cin>>s;
vector<string> v1;
string s1;
cin>>s1;
bool b=ind.find(s)==ind.end();
while (1)
{
cin>>s1;
if (s1==";")
break;
v1.push_back(s1);
b&=ind.find(s1)!=ind.end();
}
if (!b)
{
cout<<"greska"<<endl;
continue;
}
vector<int> v;
for (auto i:v1)
v.push_back(ind[i]);
int k=v.size();
for (int i=0;i<k and b;i++)
for (int j=i+1;j<k and b;j++)
{
if (inh[v[i]][v[j]] or inh[v[j]][v[i]])
continue;
tem=inh[v[i]]&inh[v[j]];
if (tem.any())
b=0;
}
if (b)
{
cout<<"ok"<<endl;
ind[s]=ind.size();
for (int i=0;i<k;i++)
inh[ind[s]]|=inh[v[i]],inh[ind[s]].set(v[i]);
}
else
cout<<"greska"<<endl;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |