Submission #990701

#TimeUsernameProblemLanguageResultExecution timeMemory
990701vjudge1Dijamant (COI16_dijament)C++17
56 / 100
2084 ms812 KiB
#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; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...