Submission #719852

#TimeUsernameProblemLanguageResultExecution timeMemory
719852jcelinDijamant (COI16_dijament)C++14
100 / 100
324 ms852 KiB
#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] and ((~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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...