Submission #934396

#TimeUsernameProblemLanguageResultExecution timeMemory
934396bashNewbieVlak (COCI20_vlak)C++17
70 / 70
9 ms10700 KiB
#include <iostream> #include <vector> #include <algorithm> #include <string> using namespace std; #define fast_io ios::sync_with_stdio(0), cin.tie(0) #define vi vector<int> const int N = 2e5+7, K = 26; int adj[2][N][K], ctr[2]; void add(string& s, int d) { int x = 0; for(char ch: s) { int c = ch-'a', y = adj[d][x][c]; if(!y) adj[d][x][c] = ++ctr[d]; x = adj[d][x][c]; } } int dfs(int p, int q, int d) { int w = 0; for(int j = 0; j < K; j++) { int x = adj[0][p][j], y = adj[1][q][j]; if(!x) x = N-1; if(!y) y = N-1; if(d == 0 && x == N-1) continue; if(d == 1 && y == N-1) continue; w |= dfs(x, y, d^1)^1; } return w; } int main() { fast_io; int n; string s; for(int k = 0; k < 2; k++) { cin >> n; for(int i = 0; i < n; i++) { cin >> s; add(s, k); } } int ret = dfs(0, 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...