Submission #825787

#TimeUsernameProblemLanguageResultExecution timeMemory
825787taitruong270Vlak (COCI20_vlak)C++17
70 / 70
89 ms114288 KiB
#include <bits/stdc++.h> using namespace std; #define MAX 1000001 #define FOR(type, i, a, b) for(type i = (a); i <= (b); i++) int n, m; struct Node{ int lvl = 0, cnt[2] = {}; int child[26] = {}; Node(){ lvl = cnt[0] = cnt[1] = 0; FOR(int, i, 0, 25) child[i] = -1; } }; Node trie[MAX]; int len = 0; const int root = 0; void add(string s, int type){ int node = root; trie[node].cnt[type]++; int lvl = 0; for (char c: s){ int pos = c - 'a'; if (trie[node].child[pos] == -1) trie[node].child[pos] = ++len; node = trie[node].child[pos]; trie[node].lvl = ++lvl; trie[node].cnt[type]++; } } int f[MAX]; int dp(int node){ Node curr = trie[node]; int turn = curr.lvl & 1; f[node] = 0; if (!curr.cnt[turn]) return 0; FOR(int, choice, 0, 25){ int childPos = curr.child[choice]; if (childPos == -1) continue; Node child = trie[childPos]; if (dp(childPos) == 0) f[node] = 1; } return f[node]; } main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; FOR(int, i, 1, n) {string s; cin >> s; add(s, 0);} cin >> m; FOR(int, i, 1, m) {string s; cin >> s; add(s, 1);} FOR(int, i, 0, len) f[i] = -1; cout << (dp(root) ? "Nina" : "Emilija"); }

Compilation message (stderr)

Main.cpp: In function 'int dp(int)':
Main.cpp:48:8: warning: variable 'child' set but not used [-Wunused-but-set-variable]
   48 |   Node child = trie[childPos];
      |        ^~~~~
Main.cpp: At global scope:
Main.cpp:55:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   55 | main()
      | ^~~~
#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...