Submission #1021658

#TimeUsernameProblemLanguageResultExecution timeMemory
1021658TrendBattlesVlak (COCI20_vlak)C++14
70 / 70
17 ms14684 KiB
#include <bits/stdc++.h> using namespace std; using lli = int64_t; #define INFILE "vlak.inp" #define OUTFILE "vlak.out" const int MAX_AL = 26; struct Node { int available = 0; int child[MAX_AL]; Node() { memset(child, -1, sizeof child); } }; vector <Node> trie(1); void add(const string& s, int who) { int now = 0; for (char x : s) { int nxt = trie[now].child[x - 'a']; if (nxt == -1) { nxt = trie.size(); trie[now].child[x - 'a'] = nxt; trie.emplace_back(); } now = nxt; trie[now].available |= 1 << who; } } int main() { ios::sync_with_stdio(0); cin.tie(0); if (fopen(INFILE, "r")) { freopen(INFILE, "r", stdin); freopen(OUTFILE, "w", stdout); } for (int i : {0, 1}) { int N; cin >> N; for (int t = 1; t <= N; ++t) { string S; cin >> S; add(S, i); } } vector <int> dp((int) trie.size() + 100, -1); auto DP = [&] (auto self, int u, int turn) -> int { int& now = dp[u]; if (now != -1) return now; now = 0; for (int i = 0; i < 26; ++i) { if (trie[u].child[i] == -1) continue; int v = trie[u].child[i]; if ((trie[v].available >> turn & 1) == 0) continue; now |= not self(self, v, turn ^ 1); } return now; }; cout << (DP(DP, 0, 0) ? "Nina" : "Emilija"); return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:36:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |         freopen(INFILE, "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~
Main.cpp:37:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |         freopen(OUTFILE, "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#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...