# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
744524 | 2023-05-18T16:46:12 Z | nvujica | Dijamant (COI16_dijament) | C++14 | 2000 ms | 340 KB |
#include <bits/stdc++.h> #define ll long long #define fi first #define se second using namespace std; const int maxn = 1010; int n, cnt; bool ok; map <string, int> mp; int d[maxn]; int bio[maxn]; vector <int> par[maxn]; void rek(int x, int br){ if(bio[x] && bio[x] != br){ ok = 0; return; } bio[x] = br; for(int i = 0; i < par[x].size(); i++){ rek(par[x][i], br); if(!ok) return; } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for(int j = 0; j < n; j++){ string k, p; cin >> k; cin >> p; ok = 1; if(mp[k]) ok = 0; vector <pair<int, int> > v; while(true){ cin >> p; if(p == ";") break; if(!mp[p]) ok = 0; else { v.push_back({d[mp[p]], mp[p]}); } } if(!ok){ cout << "greska\n"; continue; } sort(v.begin(), v.end()); reverse(v.begin(), v.end()); memset(bio, 0, sizeof bio); for(int i = 0; i < v.size(); i++){ int x = v[i].se; if(!bio[x]) rek(x, i + 1); } if(!ok){ cout << "greska\n"; continue; } cout << "ok\n"; cnt++; mp[k] = cnt; if(!v.empty()) d[cnt] = v[0].fi + 1; for(int i = 0; i < v.size(); i++){ par[cnt].push_back(v[i].se); } } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Execution timed out | 2049 ms | 340 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Execution timed out | 2049 ms | 340 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2060 ms | 340 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |