#include<bits/stdc++.h>
using namespace std;
const int N = 1001;
map<string, int> st;
map<int, string> inv;
set<string> Str;
vector<int> G[N];
bitset<N> Df[N];
int main()
{
int n;
cin >> n;
int cur = 0;
for(int i = 0; i < n; i ++)
{
string k;
cin >> k;
string temp; cin >> temp;
bool ok = true;
//cerr << k << endl;
ok &= (Str.count(k) == 0);
// cerr << "ok = " << ok << endl;
while(true)
{
cin >> temp;
if(temp == ";")
break;
if(st.count(temp) == 0)
ok = false;
G[cur].push_back(st[temp]);
Df[cur] |= Df[G[cur].back()];
Df[cur].set(G[cur].back(), 1);
}
if(ok)
{
// cerr << Df[cur] << endl;
for(int i = 0; i < cur && ok; i++)
{
if(!Df[cur].test(i)) continue;
for(int j = i + 1; j < cur && ok; j++)
{
if(!Df[cur].test(j)) continue;
if(Df[i].test(j) || Df[j].test(i))
continue;
bitset<N> A = Df[i] & Df[j];
if(A.any())
ok = false;
}
}
if(ok)
{
Str.insert(k);
inv[cur] = k;
st[k] = cur++;
cout << "ok\n";
}
else
{
G[cur].clear();
Df[cur].reset();
cout << "greska\n";
}
}
else
{
// cerr << Df[cur] << endl;
Df[cur].reset();
G[cur].clear();
cout << "greska\n";
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
456 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
456 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
456 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
320 ms |
3088 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |