#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 |
1 |
Correct |
1 ms |
556 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
556 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
3 ms |
568 KB |
Output is correct |
7 |
Correct |
2 ms |
604 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
556 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
3 ms |
568 KB |
Output is correct |
7 |
Correct |
2 ms |
604 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
552 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
2 ms |
604 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
360 KB |
Output is correct |
18 |
Correct |
1 ms |
560 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
383 ms |
4140 KB |
Output is correct |
2 |
Correct |
454 ms |
4692 KB |
Output is correct |
3 |
Correct |
127 ms |
4568 KB |
Output is correct |
4 |
Correct |
2 ms |
604 KB |
Output is correct |
5 |
Correct |
3 ms |
620 KB |
Output is correct |
6 |
Correct |
8 ms |
660 KB |
Output is correct |
7 |
Correct |
10 ms |
688 KB |
Output is correct |
8 |
Correct |
24 ms |
836 KB |
Output is correct |
9 |
Correct |
19 ms |
996 KB |
Output is correct |
10 |
Correct |
8 ms |
568 KB |
Output is correct |
11 |
Correct |
5 ms |
604 KB |
Output is correct |
12 |
Correct |
358 ms |
4048 KB |
Output is correct |