답안 #531501

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
531501 2022-03-01T00:14:12 Z colazcy Dijamant (COI16_dijament) C++17
56 / 100
2000 ms 628 KB
#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;
}
# 결과 실행 시간 메모리 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 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 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 1 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 336 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 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 1 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 336 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 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 2 ms 332 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2057 ms 628 KB Time limit exceeded
2 Halted 0 ms 0 KB -