#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
int n, nod;
map<string, int> id;
bitset<1007> gph[1007], rv[1007], prec[1007], emp, ch;
bool check(){
FOR(i, 1, nod + 1) if(!emp[i]) if(((~gph[i] & prec[i]) & emp).count()) return 1;
return 0;
}
int main(){
cin >> n;
REP(i, n){
string cur, e;
cin >> cur >> e;
if(id[cur]){
while(1){
cin >> e;
if(e == ";") break;
}
cout << "greska\n";
continue;
}
emp.reset();
int fl = 1;
while(1){
cin >> e;
if(e == ";") break;
fl = min(fl, id[e]);
emp[id[e]] = 1;
}
if(fl == 0 or check()){
cout << "greska\n";
continue;
}
id[cur] = ++nod;
REP(i, nod) if(emp[i]) emp |= gph[i];
REP(i, nod) if(emp[i]) prec[nod] |= rv[i], rv[i][nod] = 1;
gph[nod] = emp;
cout << "ok\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
3 ms |
340 KB |
Output is correct |
7 |
Correct |
3 ms |
212 KB |
Output is correct |
8 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
3 ms |
340 KB |
Output is correct |
7 |
Correct |
3 ms |
212 KB |
Output is correct |
8 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
259 ms |
888 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |