#include <bits/stdc++.h>
using namespace std;
int main()
{
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<<endl;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
504 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
504 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
12 ms |
348 KB |
Output is correct |
7 |
Correct |
3 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 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
504 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
12 ms |
348 KB |
Output is correct |
7 |
Correct |
3 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 |
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 |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
432 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 |
344 KB |
Output is correct |
20 |
Correct |
2 ms |
348 KB |
Output is correct |
21 |
Correct |
2 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2084 ms |
812 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |