#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x) x.begin(), x.end()
const int M = 1007;
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
const double eps = 1e-6;
const int dx[] = {0, -1, 0, 1}, dy[] = {1, 0, -1, 0};
const int block = 320;
map <string, int> mp;
string who[M];
vector <int> roots[M], v[M];
int n, dep[M][M], p[M][M], cmproot;
bool cmp(int a, int b){
return dep[a][cmproot] > dep[b][cmproot];
}
int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n;
for(int i = 1; i <= n; ++i){
string s2; vector <int> tmp; bool ok = 1;
cin >> s2;
// if(mp[s]) ok = 0;
// else mp[s] = i;
// int node = mp[s];
// who[node] = s;
while(1){
string s;
cin >> s;
if(s == ":") continue;
if(s == ";") break;
// if(mp[s] == 0 || mp[s] == node) ok = 0;
// tmp.pb(mp[s]);
}
if(mp[s2]) cout << "greska\n";
else{
mp[s2] = i;
cout << "ok\n";
}
// if(tmp.empty()){
// roots[node].pb(node);
// dep[node][node] = 1;
// }
//
// for(auto j : tmp)
// for(auto k : roots[j])
// v[k].pb(j);
//
// for(int root = 1; root <= i; ++root) if(v[root].size()){
// cmproot = root;
// sort(all(v[root]), cmp);
//
// p[node][root] = v[root][0];
// dep[node][root] = dep[v[root][0]][root] + 1;
// roots[node].pb(root);
//
// int cur = node;
// for(auto j : v[root]){
// while(dep[j][root] < dep[cur][root]) cur = p[cur][root];
//
// if(dep[cur][root] == dep[j][root] && cur != j) ok = 0;
// }
//
// v[root].clear();
// }
// if(ok) cout << "ok\n";
// else{
// cout << "greska\n";
//
// for(int root = 1; root <= n; ++root){
// p[node][root] = 0;
// dep[node][root] = 0;
// }
// roots[node].clear();
// mp[who[node]] = 0;
// who[node] = "";
// }
}
return 0;
}
Compilation message
dijament.cpp: In function 'int main()':
dijament.cpp:31:43: warning: unused variable 'ok' [-Wunused-variable]
31 | string s2; vector <int> tmp; bool ok = 1;
| ^~
# |
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 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
8 |
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 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
44 ms |
460 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |