Submission #1168381

#TimeUsernameProblemLanguageResultExecution timeMemory
1168381nuutsnoyntonVlak (COCI20_vlak)C++20
10 / 70
25 ms20036 KiB
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
const ll M = 1e6 + 1;
ll type, node_count = 0;;
ll trie[M][26];
ll cnt[M];
void add_string(string str) {
	ll node = 0;
	for ( char ch : str) {
		if ( trie[node][ch - 'a'] == 0) trie[node][ch-'a'] = ++node_count;
		node = trie[node][ch - 'a'];
		cnt[node] += type;
	}
}

int main() {
	ll n, m, r, x,p, y, i, j,s, ans, t;

	cin >> n;
	
	
	string str1[n + 2];
	type = 1;
	for (i = 0; i < n; i ++) {
		cin >> str1[i];
		add_string(str1[i]);
	}
	cin >> m;
	type = 1;
	string str2[m + 2];
	for (i = 0; i < m; i ++) {
		cin >> str2[i];
		add_string(str2[i]);
	}
	
	queue < ll > q, v;
	q.push(0);
	type = 1;
	while (1) {
		while(!q.empty()) {
			r = q.front();
			q.pop();
			for (j = 0; j < 26; j ++) {
				p = trie[r][j];
				if (p == 0) continue;
				s = cnt[p] & type;
				if (s != 0) {
					v.push(p);
				}
			}
		}
		if ( v.empty()) break;
		swap(v, q);
		type = 3 - type;
	}
	if ( type == 2) cout << "Nina" << endl;
	else cout << "Emilija" << endl;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...