Submission #986018

#TimeUsernameProblemLanguageResultExecution timeMemory
986018LOLOLOVlak (COCI20_vlak)C++17
70 / 70
27 ms20568 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; #define f first #define s second #define pb push_back #define ep emplace #define eb emplace_back #define lb lower_bound #define ub upper_bound #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define uniquev(v) sort(all(v)), (v).resize(unique(all(v)) - (v).begin()) #define mem(f,x) memset(f , x , sizeof(f)) #define sz(x) (int)(x).size() #define __lcm(a, b) (1ll * ((a) / __gcd((a), (b))) * (b)) #define mxx *max_element #define mnn *min_element #define cntbit(x) __builtin_popcountll(x) #define len(x) (int)(x.length()) const int N = 2e5 + 10; const int M = 1e7 + 10; struct node { int prefix_count; bool f = 0, s = 0, df = 0, ds = 0; struct node *child[26]; } *head; void init() { head = new node(); } void insert(string word, int c) { node *current = head; for (int i = 0 ; i < (int)word.length(); ++i) { int letter = (int)word[i] - (int)'a'; if (current->child[letter] == NULL) current->child[letter] = new node(); current = current->child[letter]; if (c == 0) { current->f = 1; } else { current->s = 1; } } } void dfs(node *head) { head->ds = head->s; head->df = head->f; for (int i = 0; i < 26; i++) { if (head->child[i] != NULL) { dfs(head->child[i]); if (head->child[i]->ds) { head->df = 0; } if (head->child[i]->df) { head->ds = 0; } } } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); init(); head->f = head->s = 1; int n; cin >> n; for (int i = 0; i < n; i++) { string s; cin >> s; insert(s, 0); } int m; cin >> m; for (int i = 0; i < m; i++) { string s; cin >> s; insert(s, 1); } dfs(head); if (head->ds == 1) { cout << "Emilija\n"; } else { cout << "Nina\n"; } return 0; }
#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...