Submission #934381

#TimeUsernameProblemLanguageResultExecution timeMemory
934381bashNewbieVlak (COCI20_vlak)C++17
0 / 70
11 ms18268 KiB
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <utility> using namespace std; #define fast_io ios::sync_with_stdio(0), cin.tie(0) #define vi vector<int> #define pi pair<int, int> #define fv first const int N = 2e5+7, K = 26; pi adj[N][K]; int len; void add(string& s, int d) { int x = 0; for(char ch: s) { int c = ch-'a'; auto [y, f] = adj[x][c]; if(y) f += d; else adj[x][c] = {len++, d}; x = adj[x][c].fv; } } int dfs(int x, int r) { int wx = 0; for(auto [y, f]: adj[x]) { if(!y) continue; if(r&1) { if(f > -1) { int wy = dfs(y, r^1); wx |= wy^1; } } else { if(f < 1) { int wy = dfs(y, r^1); wx |= wy^1; } } } return wx; } int main() { fast_io; len = 1; int n; string s; for(int k = -1; k < 2; k++) { if(!k) continue; cin >> n; for(int i = 0; i < n; i++) { cin >> s; add(s, k); } } int ret = dfs(0, 0); cout << (ret? "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...