# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
104795 |
2019-04-09T09:28:37 Z |
Shtef |
Dijamant (COI16_dijament) |
C++14 |
|
1957 ms |
52260 KB |
#include <iostream>
#include <map>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
typedef pair <int, string> psi;
#define x first
#define y second
#define mp make_pair
map <string, bool> m;
map <string, int> dth;
map <string, map <psi, bool, greater <psi> > > svi;
int n;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
for(int i = 0 ; i < n ; ++i){
string s;
cin >> s;
char poc;
cin >> poc;
map <string, bool> ovaj;
while(1){
string x;
cin >> x;
if(x == ";")
break;
ovaj[x] = 1;
}
if(m.find(s) != m.end()){
cout << "greska" << endl;
continue;
}
bool p = 1;
int sad = 0;
map <psi, bool, greater <psi> > taj;
for(map <string, bool>::iterator j = ovaj.begin() ; j != ovaj.end() ; ++j){
string x = j->x;
if(m.find(x) == m.end()){
p = 0;
break;
}
sad = max(sad, dth[x] + 1);
taj[mp(dth[x], x)] = 1;
}
/*
for(map <psi, bool>::iterator j = taj.begin() ; j != taj.end() ; ++j){
psi o = j->x;
cout << o.y << " : " << o.x << endl;
}
*/
if(!p){
cout << "greska" << endl;
continue;
}
map <string, bool> gornji;
for(map <psi, bool>::iterator j = taj.begin() ; j != taj.end() ; ++j){
string x = (j->x).y;
if(gornji.find(x) != gornji.end())
continue;
for(map <psi, bool>::iterator v = svi[x].begin() ; v != svi[x].end() ; ++v){
string y = (v->x).y;
if(gornji.find(y) != gornji.end()){
p = 0;
break;
}
gornji[y] = 1;
}
if(!p)
break;
}
if(!p){
cout << "greska" << endl;
continue;
}
cout << "ok" << endl;
m[s] = 1;
dth[s] = sad;
gornji.clear();
for(map <psi, bool>::iterator j = taj.begin() ; j != taj.end() ; ++j){
string x = (j->x).y;
if(svi[s].find(mp(dth[x], x)) != svi[s].end())
continue;
svi[s][mp(dth[x], x)] = 1;
for(map <psi, bool>::iterator v = svi[x].begin() ; v != svi[x].end() ; ++v){
string y = (v->x).y;
svi[s][mp(dth[y], y)] = 1;
}
}
//cout << endl << endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
16 ms |
896 KB |
Output is correct |
7 |
Correct |
6 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
3 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
16 ms |
896 KB |
Output is correct |
7 |
Correct |
6 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
3 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
3 ms |
512 KB |
Output is correct |
13 |
Correct |
3 ms |
384 KB |
Output is correct |
14 |
Correct |
3 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
3 ms |
384 KB |
Output is correct |
17 |
Correct |
4 ms |
512 KB |
Output is correct |
18 |
Correct |
6 ms |
512 KB |
Output is correct |
19 |
Correct |
4 ms |
512 KB |
Output is correct |
20 |
Correct |
4 ms |
384 KB |
Output is correct |
21 |
Correct |
4 ms |
384 KB |
Output is correct |
22 |
Correct |
3 ms |
384 KB |
Output is correct |
23 |
Correct |
4 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1831 ms |
46228 KB |
Output is correct |
2 |
Correct |
1957 ms |
52260 KB |
Output is correct |
3 |
Correct |
233 ms |
4728 KB |
Output is correct |
4 |
Correct |
12 ms |
812 KB |
Output is correct |
5 |
Correct |
22 ms |
1244 KB |
Output is correct |
6 |
Correct |
45 ms |
1144 KB |
Output is correct |
7 |
Correct |
46 ms |
1144 KB |
Output is correct |
8 |
Correct |
79 ms |
1272 KB |
Output is correct |
9 |
Correct |
70 ms |
1196 KB |
Output is correct |
10 |
Correct |
28 ms |
888 KB |
Output is correct |
11 |
Correct |
17 ms |
768 KB |
Output is correct |
12 |
Correct |
1578 ms |
42476 KB |
Output is correct |