Submission #988801

#TimeUsernameProblemLanguageResultExecution timeMemory
988801HasanV11010238Vlak (COCI20_vlak)C++17
70 / 70
38 ms24656 KiB
#include <bits/stdc++.h> using namespace std; #define INF 1000000000 #define mod 998244353 #define ll long long int numbr = 0; class Node{ public: unordered_map<char, Node*> childs; vector<int> col; int num = 0; Node(int nu){ num = nu; col.assign(2, 0); } }; Node* create(){ Node* node = new Node(numbr); numbr++; return node; } void add(Node* root, string s, int co){ Node* curr = root; for (auto v : s){ if (curr->childs.find(v) == curr->childs.end()){ curr->childs[v] = create(); } curr = curr->childs[v]; curr->col[co] = 1; } } vector<int> dp(numbr + 1, 2); void dfs(Node* curr, int turn){ dp[curr->num] = 1 - turn; int am = 0, an = 0; for (auto el : curr->childs){ if (el.second->col[turn] == 1){ am++; dfs(el.second, 1 - turn); } else{ an++; } if ((dp[el.second->num] == turn) && el.second->col[turn] == 1){ dp[curr->num] = turn; } } /*if (am == 0 && an == 0){ dp[curr->num] = turn; }*/ } int main(){ int n, m; string s; Node* root = create(); cin>>n; for (int i = 0; i < n; i++){ cin>>s; add(root, s, 0); } cin>>m; for (int i = 0; i < m; i++){ cin>>s; add(root, s, 1); } dp.assign(numbr + 1, 2); dfs(root, 0); if (dp[0] == 0){ cout<<"Nina"; } else{ cout<<"Emilija"; } }
#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...