#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;
continue;
}
}
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 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2067 ms |
1372 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |