Submission #719852

# Submission time Handle Problem Language Result Execution time Memory
719852 2023-04-06T21:58:55 Z jcelin Dijamant (COI16_dijament) C++14
100 / 100
324 ms 852 KB
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
int n, nod;
map<string, int> id;
bitset<1007> gph[1007], rv[1007], prec[1007], emp, ch;
bool check(){
	FOR(i, 1, nod + 1) if(emp[i] and ((~gph[i] & prec[i]) & emp).count()) return 1;
	return 0;
}
int main(){
	cin >> n;
	REP(i, n){
		string cur, e;
		cin >> cur >> e;
		if(id[cur]){
			while(1){
				cin >> e;
				if(e == ";") break;	
			}
			cout << "greska\n";
			continue;
		}
		
		emp.reset();
		int fl = 1;
		while(1){
			cin >> e;
			if(e == ";") break;
			fl = min(fl, id[e]);
			emp[id[e]] = 1;
		}
		
		if(fl == 0 or check()){
			cout << "greska\n";
			continue;
		}
		
		id[cur] = ++nod;
		REP(i, nod) if(emp[i]) emp |= gph[i];
		REP(i, nod) if(emp[i]) prec[nod] |= rv[i], rv[i][nod] = 1; 
		gph[nod] = emp;
		cout << "ok\n";
	}
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 3 ms 340 KB Output is correct
7 Correct 3 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 3 ms 340 KB Output is correct
7 Correct 3 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 3 ms 212 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 273 ms 840 KB Output is correct
2 Correct 324 ms 736 KB Output is correct
3 Correct 258 ms 392 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 4 ms 596 KB Output is correct
6 Correct 8 ms 468 KB Output is correct
7 Correct 15 ms 552 KB Output is correct
8 Correct 26 ms 480 KB Output is correct
9 Correct 27 ms 516 KB Output is correct
10 Correct 8 ms 468 KB Output is correct
11 Correct 8 ms 428 KB Output is correct
12 Correct 291 ms 852 KB Output is correct