# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
743625 | lukadupli | Dijamant (COI16_dijament) | C++14 | 2033 ms | 888 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1005;
int n, cnt = 0;
map<string, int> mapa;
bitset<MAXN> bs[MAXN];
bool add(string& klasa, vector<string>& dads){
if(mapa.find(klasa) != mapa.end()) return 0;
for(string& d : dads) if(mapa.find(d) == mapa.end()) return 0;
bitset<MAXN> b;
for(int i = 0; i < dads.size(); i++){
for(int j = i + 1; j < dads.size(); j++){
int d1 = mapa[dads[i]], d2 = mapa[dads[j]];
if(!bs[d2][d1] && !bs[d1][d2] && (bs[d1] & bs[d2]).count()) return 0;
}
b |= bs[mapa[dads[i]]];
}
mapa[klasa] = ++cnt;
b[cnt] = 1;
bs[cnt] = b;
return 1;
}
int main()
{
cin >> n;
for(int i = 0; i < n; i++){
string k;
cin >> k;
char c;
cin >> c;
vector<string> dads;
string in = "";
while(in != ";"){
cin >> in;
dads.push_back(in);
}
dads.pop_back();
if(add(k, dads)) cout << "ok\n";
else cout << "greska\n";
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |