Submission #445514

# Submission time Handle Problem Language Result Execution time Memory
445514 2021-07-18T12:26:48 Z grt Vlak (COCI20_vlak) C++17
10 / 70
65 ms 5768 KB
#include <bits/stdc++.h>
#define ST first
#define ND second
#define PB push_back

using namespace std;
using ll = long long;
using pi = pair<int,int>;
using vi = vector<int>;

const int mod = 1012414159, p = 317;
int n, m;
set<int>pl[2];
map<pair<int, bool>, bool>mp;

void rec(int hsh, bool turn) {
	bool win = false;
	for(int i = 1; i <= 26; ++i) {
		int h2 = ((ll)hsh * p + i) % mod;
		if(pl[turn].count(h2)) {
			if(!mp.count({h2, turn ^ 1})) rec(h2, turn ^ 1);
			if(!mp[{h2, turn ^ 1}]) win = true;
		}
	}
	mp[{hsh, turn}] = win;
}


int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for(int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		int hsh = 0;
		for(auto c : s) {
			hsh = ((ll)hsh * p + (c - 'a' + 1)) % mod;
			pl[0].insert(hsh);
		}
	}
	cin >> m;
	for(int i = 0; i < m; ++i) {
		string s;
		cin >> s;
		int hsh = 0;
		for(auto c : s) {
			hsh = ((ll)hsh * p + (c - 'a' + 1)) % mod;
			pl[1].insert(hsh);
		}
	}
	rec(0, 1);
	if(mp[{0, 1}]) cout << "Nina";
	else cout << "Emilija";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Incorrect 1 ms 332 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Incorrect 1 ms 332 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Incorrect 1 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 65 ms 5688 KB Output is correct
2 Incorrect 63 ms 5388 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 61 ms 5564 KB Output is correct
2 Incorrect 63 ms 5768 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 62 ms 5444 KB Output is correct
2 Incorrect 60 ms 5264 KB Output isn't correct
3 Halted 0 ms 0 KB -