# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
244353 | 2020-07-03T17:07:25 Z | MatesV13 | Dijamant (COI16_dijament) | C++11 | 242 ms | 2908 KB |
#include <bits/stdc++.h> using namespace std; map<string, int> imi; vector<int> c[1005]; string ime_klase, nadklase; int v[1005], us[1005]; bool ok; bool dohvatljivi[1005][1005]; int n, br; queue<pair<int, int> > xx; bool check(int idx){ while (xx.size()) xx.pop(); for (int i=0; i<c[idx].size(); i++){ bool kk=1; for (int j=0; j<c[idx].size(); j++) if (dohvatljivi[c[idx][i]][c[idx][j]]) kk=0; if (kk) xx.push(make_pair(c[idx][i], c[idx][i])); } for (int i=1; i<br; i++) v[i]=0; while (!xx.empty()){ int cur = (xx.front()).first; int par = (xx.front()).second; if (v[cur] and v[cur]!=par) return 0; xx.pop(); if (v[cur]) continue; v[cur]=par; for (int i=0; i<c[cur].size(); i++) xx.push(make_pair(c[cur][i], par)); } return 1; } int main (){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; br=0; while (n--){ cin >> ime_klase >> nadklase; br++; ok=1; if (imi.count(ime_klase)) ok=0; while (true){ cin >> nadklase; if (nadklase==";") break; if (imi.count(nadklase)) c[br].push_back(imi[nadklase]); else {ok=0; continue;} } // if (ok) ok=check(br); if (ok) { for (int i=1; i<br; i++) if (v[i]) dohvatljivi[i][br]=1; imi[ime_klase]=br; cout << "ok\n"; } else {c[br].clear(); br--; cout << "greska\n";} } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 6 ms | 512 KB | Output is correct |
7 | Correct | 6 ms | 384 KB | Output is correct |
8 | Correct | 5 ms | 384 KB | Output is correct |
9 | Correct | 5 ms | 384 KB | Output is correct |
10 | Correct | 5 ms | 404 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 6 ms | 512 KB | Output is correct |
7 | Correct | 6 ms | 384 KB | Output is correct |
8 | Correct | 5 ms | 384 KB | Output is correct |
9 | Correct | 5 ms | 384 KB | Output is correct |
10 | Correct | 5 ms | 404 KB | Output is correct |
11 | Incorrect | 5 ms | 384 KB | Output isn't correct |
12 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 242 ms | 2908 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |