# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
123639 | sams | Dijamant (COI16_dijament) | C++14 | 1996 ms | 8708 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 = 1e3+10;
int n, N;
int nd, mk[maxn][maxn];
map<string, int> conv;
int main()
{
cin >> n;
N = n;
while(N--)
{
string c, pt;
cin >> c >> pt;
set<string> II;
vector<int> g;
while(true)
{
string ss;
cin >> ss;
if(ss == ";") break;
II.insert(ss);
}
if(conv.find(c) != conv.end())
{
cout << "greska\n";
continue;
}
int ok = 0;
conv[c] = ++nd;
for(auto ii: II)
{
if(conv.find(ii) == conv.end())
{
ok = 1;
break;
}
g.push_back(conv[ii]);
}
if(ok)
{
conv.erase(c);
nd--;
cout << "greska\n";
continue;
}
for(int i = 0 ; i < g.size() ; ++i)
{
for(int j = i+1 ; j < g.size() ; ++j)
{
int a = g[i], b = g[j];
if(mk[a][b] == 1 || mk[b][a] == 1) continue;
for(int k = 1 ; k < nd ; ++k)
{
if(mk[a][k] == 1 && mk[b][k] == 1)
{
ok = 1;
break;
}
}
}
if(ok) break;
}
if(ok)
{
nd--;
conv.erase(c);
cout << "greska\n";
continue;
}
for(int u: g)
{
mk[nd][u] = 1;
for(int i = 1 ; i < nd ; ++i)
if(mk[u][i]) mk[nd][i] = 1;
}
cout << "ok\n";
/*for(int i = 1 ; i <= nd ;++i)
{
for(int j = 1 ; j <= nd ; ++j)
{
cout << mk[i][j] << " \n"[j == nd];
}
}*/
}
}
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... |