Submission #988800

#TimeUsernameProblemLanguageResultExecution timeMemory
988800HasanV11010238Vlak (COCI20_vlak)C++17
0 / 70
45 ms23632 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<<"Alice"; } else{ cout<<"Bob"; } }
#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...