Submission #881015

#TimeUsernameProblemLanguageResultExecution timeMemory
881015TAhmed33Vlak (COCI20_vlak)C++98
70 / 70
16 ms43096 KiB
#include <bits/stdc++.h> using namespace std; int a[200001][26]; int b[200001][26]; int sze1 = 0, sze2 = 0; void insert1 (string s) { int cur = 0; for (auto i : s) { if (a[cur][i - 'a'] == -1) a[cur][i - 'a'] = ++sze1; cur = a[cur][i - 'a']; } } void insert2 (string s) { int cur = 0; for (auto i : s) { if (b[cur][i - 'a'] == -1) b[cur][i - 'a'] = ++sze2; cur = b[cur][i - 'a']; } } int dp[200001][2]; int ans (int x, int y, int c) { int &ret = dp[x][c]; if (ret != -1) return ret; ret = 0; if (!c) { for (int i = 0; i < 26; i++) { if (a[x][i] != -1 && b[y][i] == -1) { ret = 1; } else if (a[x][i] != -1) { ret |= !ans(a[x][i], b[y][i], 1); } } } else { for (int i = 0; i < 26; i++) { if (b[y][i] != -1 && a[x][i] == -1) { ret = 1; } else if (b[y][i] != -1) { ret |= !ans(a[x][i], b[y][i], 0); } } } return ret; } int main () { memset(a, -1, sizeof(a)); memset(b, -1, sizeof(b)); memset(dp, -1, sizeof(dp)); int n; cin >> n; while (n--) { string s; cin >> s; insert1(s); } cin >> n; while (n--) { string s; cin >> s; insert2(s); } cout << (ans(0, 0, 0) ? "Nina" : "Emilija") << '\n'; }
#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...