Submission #1006575

#TimeUsernameProblemLanguageResultExecution timeMemory
1006575vjudge1Vlak (COCI20_vlak)C++17
70 / 70
20 ms61688 KiB
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; int n, m, sz = 1, nxt[3][N][26], lvl; bool win[N]; void add(string s, int id){ int cur = 0; for (int i = 0; i < s.size(); i ++){ char c = s[i]; int e = s[i] - 'a'; if (nxt[2][cur][e] == -1){ nxt[2][cur][e] = sz; nxt[id][cur][e] = sz; sz++; } else nxt[id][cur][e] = nxt[2][cur][e]; // cout << cur << " -- " << c << " -- "; cur = nxt[2][cur][e]; // cout << cur << endl; } } void dfs(int v){ bool leaf = 1; for (int e = 0; e < 26; e ++){ if (nxt[2][v][e] == -1) continue; int u = nxt[2][v][e]; lvl++; dfs(u); lvl++; if (nxt[lvl % 2][v][e] != -1){ leaf = 0; win[v] |= !win[u]; } } if (leaf) win[v] = 0; } int main(){ memset(nxt, -1, sizeof nxt); cin >> n; string s; for (int i = 0; i < n; i ++){ cin >> s; add(s, 0); } cin >> m; for (int i = 0; i < m; i ++){ cin >> s; add(s, 1); } dfs(0); cout << (win[0] ? "Nina" : "Emilija") << endl; }

Compilation message (stderr)

Main.cpp: In function 'void add(std::string, int)':
Main.cpp:10:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for (int i = 0; i < s.size(); i ++){
      |                     ~~^~~~~~~~~~
Main.cpp:11:14: warning: unused variable 'c' [-Wunused-variable]
   11 |         char c = s[i];
      |              ^
#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...