# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
963457 | riariti | Dijamant (COI16_dijament) | C++17 | 1597 ms | 4724 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>
namespace MX {
constexpr int N = 1E3 + 9;
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int N;
std::cin >> N;
std::map<std::string, int> cc;
std::vector anc(N, std::bitset<MX::N>(0));
for (int k = 0; k < N; k++) {
std::string K;
std::cin >> K;
bool bad = cc.count(K);
std::vector<int> P;
std::string s;
std::cin >> s;
while (true) {
std::cin >> s;
if (s == ";") {
break;
}
if (!cc.count(s)) {
bad = true;
continue;
}
auto v = cc[s];
P.push_back(v);
anc[k] |= anc[v];
anc[k][v] = true;
}
for (int i = 0; i < P.size() && !bad; i++) {
for (int j = i + 1; j < P.size() && !bad; j++) {
auto u = P[i];
auto v = P[j];
auto f = anc[u] & anc[v];
if (f.any()) {
bad |= !(anc[u][v] || anc[v][u]);
}
}
}
if (bad) {
std::cout << "greska\n";
continue;
}
std::cout << "ok\n";
cc[K] = k;
}
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... |