This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 = 1e9 + 7, p = 31;
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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |