Submission #719850

# Submission time Handle Problem Language Result Execution time Memory
719850 2023-04-06T21:52:02 Z jcelin Dijamant (COI16_dijament) C++14
100 / 100
231 ms 4056 KB
#include <bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

#define ii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vii vector<ii>
#define vll vector<ll>
#define vpll vector<pll>
#define msi multiset<int>
#define si set<int>
#define PB push_back
#define PF push_front
#define PPB pop_back
#define PPF pop_front
#define X first
#define Y second
#define MP make_pair
#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()

const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = mod;
const ll INF = 1e18;
const int logo = 20;
const int MAXN = 1e3 + 7;
const int off = 1 << logo;
const int trsz = off << 1;

int n, nod = 0;
map<string, int> id;
bitset<MAXN> gph[MAXN], rv[MAXN], prec[MAXN], emp, ch;

bool check(){
	FOR(i, 1, nod + 1){
		if(!emp[i]) continue;
		ch = (~gph[i] & prec[i]) & emp;
		if(ch.count()) return 1;
	}
	return 0;
}
void solve(){
	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];
		REP(i, nod) if(emp[i]) rv[i][nod] = 1; 
		gph[nod] = emp;
		cout << "ok\n";
	}
}


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t=1;
	//cin >> t;
	while(t--)solve();
	return 0;
}




# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 332 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 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 0 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 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 194 ms 732 KB Output is correct
2 Correct 231 ms 728 KB Output is correct
3 Correct 166 ms 420 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 3 ms 604 KB Output is correct
6 Correct 7 ms 580 KB Output is correct
7 Correct 9 ms 724 KB Output is correct
8 Correct 15 ms 932 KB Output is correct
9 Correct 16 ms 840 KB Output is correct
10 Correct 6 ms 608 KB Output is correct
11 Correct 5 ms 600 KB Output is correct
12 Correct 178 ms 4056 KB Output is correct