#include <bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
set<string> add;
int n;
cin>>n;
bitset<1000> inh[n],der[n],t,t1,dec;
map<string,int> ind;
for (int oops=0;oops<n;oops++)
{
string s;
cin>>s;
string ans="ok";
if (add.find(s)!=add.end())
ans="greska";
string s1;
vector<string> v;
cin>>s1;
while (1)
{
cin>>s1;
if (s1==";")
break;
if (add.find(s1)==add.end())
ans="greska";
v.push_back(s1);
}
if (ans=="ok")
{
ind[s]=add.size();
add.insert(s);
for (auto i:v)
{
inh[ind[s]].set(ind[i]);
inh[ind[s]]|=inh[ind[i]];
}
for (int i=0;i<n;i++)
if (inh[ind[s]][i])
der[i].set(ind[s]);
for (int i=0;i<n;i++)
{
if (!inh[ind[s]][i])
continue;
t=der[i]&inh[ind[s]];
dec.reset();
for (int j=0;j<n;j++)
if (t[j])
{
t1=inh[j]&dec;
if (!t1.count())
dec.set(j);
}
if (dec.count()>1)
{
ans="greska";
break;
}
}
if (ans=="greska")
{
for (int i=0;i<n;i++)
if (inh[ind[s]][i])
der[i].set(ind[s],0);
inh[ind[s]].reset();
ind.erase(s);
add.erase(s);
}
}
cout<<ans<<'\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
11 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 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 |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
11 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 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 |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
5 ms |
348 KB |
Output is correct |
19 |
Correct |
2 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 |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2032 ms |
1024 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |