#include <cstdio>
#include <iostream>
#include <string>
#include <map>
#include <cassert>
#include <bitset>
#include <vector>
#define let const auto
#define rep(name,beg,end) for(auto lim_##name = end,name = beg;name <= lim_##name;name++)
#define per(name,beg,end) for(auto lim_##name = end,name = beg;name >= lim_##name;name--)
#define repn(lim) for(auto REPN_lIM = lim,REPN = 1;REPN <= REPN_lIM;REPN++)
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define trace() debug("line : %d, Function : %s\n",__LINE__,__FUNCTION__)
constexpr int maxn = 1003;
int n,tot;
std::map<std::string,int> mp;
std::string readToken(){
std::string res;
std::cin >> res;
return res;
}
std::bitset<maxn> f[maxn];
bool find(const std::vector<int> &vec,const int x){
let it = std::lower_bound(vec.begin(),vec.end(),x);
if(it == vec.end())return false;
return *it == x;
}
int main(){
// std::freopen("dijamant.in","r",stdin);
// std::freopen("dijamant.out","w",stdout);
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cin >> n;
rep(id,1,n){
let now = readToken();
readToken();
std::vector<std::string> base;
while(true){
let t = readToken();
if(t == ";")break;
base.push_back(t);
}
if(mp[now]){
std::cout << "greska\n";
continue;
}
bool flg = true;
for(let &t : base)
if(!mp[t]){
flg = false;
break;
}
if(!flg){
std::cout << "greska\n";
continue;
}
for(size_t i = 0;i < base.size();i++)
for(size_t j = i + 1;j < base.size();j++){
let a = mp[base[i]],b = mp[base[j]];
if(f[a].test(b) || f[b].test(a))continue;
if((f[a] & f[b]).any()){
flg = false;
break;
}
}
if(!flg){
std::cout << "greska\n";
continue;
}
std::bitset<maxn> s;
mp[now] = ++tot;
for(let &x : base)s |= f[mp[x]];
f[tot] = s;
f[tot].set(tot);
std::cout << "ok\n";
}
// std::fclose(stdin);
// std::fclose(stdout);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
24 ms |
328 KB |
Output is correct |
7 |
Correct |
2 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
0 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
24 ms |
328 KB |
Output is correct |
7 |
Correct |
2 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
0 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
2 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2082 ms |
412 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |