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 N = 10;
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 |
---|
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... |