Submission #531532

# Submission time Handle Problem Language Result Execution time Memory
531532 2022-03-01T02:05:32 Z zlxFTH Dijamant (COI16_dijament) C++11
100 / 100
272 ms 5820 KB
#include<bits/stdc++.h>
#define LL long long
#define Rep(i,x,y) for(int i = (x), stOxrj = (y); i <= stOxrj; ++i)
#define Irep(i,x,y) for(int i = (x), stOxrj = (y); i >= stOxrj; --i)
#define il inline
#define let const auto
#define ci const int&
#define VEC vector<int>
#define pb emplace_back
#define MP make_pair
#define PA pair<int, int>
#define fi first
#define se second
#define IT iterator
using namespace std;
il int read(){
	int res = 0, flag = 1; char c = getchar();
	while( c < '0' || c > '9' ){ if( c == '-' ) flag = -1; c = getchar(); }
	while( c >= '0' && c <= '9' ) res = res * 10 + c - '0', c = getchar();
	return res * flag;
}
const int N = 1005, E = N * N;
struct edge{ int nxt, to; }e[E];
int fir[N], cnt, tot;
void add(int u, int v){ e[++tot] = (edge){fir[u], v}; fir[u] = tot; }
map<string, int> mp;
int a[N]; bool vs[N];
void Solve(){
	bool gg = 0;
	string tmp, cur; cin>>cur;
	if(mp.count(cur)) gg = 1;
	int l = 0;
	cin>>tmp;
	while(1){
		cin>>tmp;
		if(!strcmp(tmp.c_str(), ";")) break;
		if(!gg){
			if(!mp.count(tmp)) gg = 1;
			else a[++l] = mp[tmp];
		}
	}
	sort(a + 1, a + l + 1, [&](ci A, ci B){ return A > B; } );
	memset(vs, 0, sizeof(vs));
	Rep(i, 1, l) if(!gg){
		int u = a[i];
		if(vs[u]) { a[i] = 0; continue; }
		for(int j = fir[u]; j; j = e[j].nxt){
			int v = e[j].to;
			if(vs[v]) gg = 1;
			vs[v] = 1;
		}
	}
	if(gg) { puts("greska"); return ; }
	puts("ok");
	mp[cur] = ++cnt;
	Rep(i, 1, cnt - 1) if(vs[i]) add(cnt, i);
	Rep(i, 1, l) if(a[i]) add(cnt, a[i]);
	
}
signed main(){
	int n; cin>>n;
	while(n--) Solve();
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 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 300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 300 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 3 ms 312 KB Output is correct
7 Correct 2 ms 332 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 300 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 3 ms 312 KB Output is correct
7 Correct 2 ms 332 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 292 KB Output is correct
13 Correct 1 ms 304 KB Output is correct
14 Correct 1 ms 308 KB Output is correct
15 Correct 3 ms 272 KB Output is correct
16 Correct 1 ms 284 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 304 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 243 ms 5820 KB Output is correct
2 Correct 272 ms 5420 KB Output is correct
3 Correct 145 ms 1540 KB Output is correct
4 Correct 3 ms 332 KB Output is correct
5 Correct 3 ms 332 KB Output is correct
6 Correct 8 ms 452 KB Output is correct
7 Correct 16 ms 708 KB Output is correct
8 Correct 27 ms 676 KB Output is correct
9 Correct 26 ms 708 KB Output is correct
10 Correct 7 ms 444 KB Output is correct
11 Correct 6 ms 460 KB Output is correct
12 Correct 220 ms 4700 KB Output is correct