#include <bits/stdc++.h>
using namespace std;
int main()
{
set<string> add;
int n;
cin>>n;
bitset<1000> inh[n],der[n],t;
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++)
{
t=der[i]&inh[ind[s]];
if (t.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 |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
109 ms |
712 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |