Submission #897724

#TimeUsernameProblemLanguageResultExecution timeMemory
897724mihtriii295Vlak (COCI20_vlak)C++17
0 / 70
7 ms11016 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define el cout << '\n' #define TIME (1.0 * clock() / CLOCKS_PER_SEC) /* Code by Nguyen Minh Tri (mihtriii) 12TT THPT Chuyen Ben Tre */ const ll N = 3e5 + 1; ll n, m; struct Node{ Node *child[26]; int cnt; bool fn; Node(){ fn = 0; cnt = 0; memset(child, 0, sizeof(child)); } }; Node *root = new Node(); void Add(string s){ int timer = 0; Node *p = root; for (char c : s){ if (p -> child[c - 'a'] == 0 && c){ p -> child[c - 'a'] = new Node(); } p = p -> child[c - 'a']; p -> cnt = ++timer; } p -> fn = 1; } bool Querry(string s){ int timer = 0; Node *p = root; for (char c : s){ ++timer; if (p -> child[c - 'a'] == 0){ if (timer & 1) return 0; else return 1; } p = p -> child[c - 'a']; if (p -> fn) return 1; } return 1; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); if (fopen("coci2021_r3_vlak.inp", "r")){ freopen("coci2021_r3_vlak.inp", "r", stdin); freopen("coci2021_r3_vlak.out", "w", stdout); } cin >> n; for (int i = 1; i <= n; ++i){ string s; cin >> s; Add(s); } bool ok = 0; cin >> m; for (int i = 1; i <= m; ++i){ string s; cin >> s; if (Querry(s) == 0){ ok = 1; break; } } if (ok) cout << "Nina"; else cout << "Emilija"; return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:60:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   60 |   freopen("coci2021_r3_vlak.inp", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:61:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |   freopen("coci2021_r3_vlak.out", "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...