Submission #719849

# Submission time Handle Problem Language Result Execution time Memory
719849 2023-04-06T21:49:43 Z jcelin Dijamant (COI16_dijament) C++14
13 / 100
238 ms 4928 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){
		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 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 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Incorrect 1 ms 340 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 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 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Incorrect 1 ms 340 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 198 ms 656 KB Output is correct
2 Correct 238 ms 4928 KB Output is correct
3 Correct 176 ms 4504 KB Output is correct
4 Incorrect 2 ms 400 KB Output isn't correct
5 Halted 0 ms 0 KB -