Submission #448421

#TimeUsernameProblemLanguageResultExecution timeMemory
448421BERNARB01Dijamant (COI16_dijament)C++17
100 / 100
591 ms4684 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; map<string, int> vis; vector<bitset<1001>> anc(n + 1, 0); int id = 1; for (int i = 0; i < n; i++) { string tmp; getline(cin >> ws, tmp); stringstream ss; ss << tmp; string s, K; ss >> K; if (vis[K]) { cout << "greska" << '\n'; continue; } ss >> s; vector<int> v; int bl = 1; while (1) { ss >> s; if (s == ";") { break; } if (!vis[s]) { bl = 0; break; } v.push_back(vis[s]); } if (!bl) { cout << "greska" << '\n'; continue; } int m = v.size(); for (int ii = 0; ii < m; ii++) { for (int j = ii + 1; j < m; j++) { if (anc[v[ii]][v[j]] || anc[v[j]][v[ii]]) { continue; } if ((anc[v[ii]] & anc[v[j]]) != 0) { bl = 0; break; } } if (!bl) { break; } } if (!bl) { cout << "greska" << '\n'; continue; } for (int ii = 0; ii < m; ii++) { anc[id] |= anc[v[ii]]; anc[id][v[ii]] = 1; } vis[K] = id++; cout << "ok" << '\n'; } 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...