Submission #727800

#TimeUsernameProblemLanguageResultExecution timeMemory
727800madtuberVlak (COCI20_vlak)C++14
70 / 70
14 ms10392 KiB
#include <bits/stdc++.h> #define all(x) begin(x),end(x) #define fir first #define sec second #define sz(x) x.size() #define pb push_back using namespace std; using ll = long long; using vi = vector<int>; using pi = pair<int,int>; using pdb = pair<double,double>; using pll = pair<ll,ll>; using vll = vector<ll>; using ull = unsigned long long; const double EPS = (1e-6); void setio(string s){ freopen((s + ".in").c_str(),"r",stdin); freopen((s + ".out").c_str(),"w",stdout); } struct Trie{ map<char, Trie> c; pi own{0,0}; bool mark = false; void insert(int cur, string& s, int pos){ if (cur % 2) own.sec = 1; else own.fir = 1; if (pos != sz(s)) c[s[pos]].insert(cur, s, pos+1); else mark = true; } //if cur % 2, a's turn, else b's turn int dfs(int cur){ if (cur % 2){ int res = 0; for(auto& j : c){ if (j.sec.own.sec){ res = max(res, j.sec.dfs(cur+1)); } } return res; }else{ int res = 1; for(auto& j : c){ if (j.sec.own.fir){ res = min(res, j.sec.dfs(cur+1)); } } return res; } } }; void solve(){ int n; cin >> n; Trie tr; for(int i{}; i < n; i++){ string s; cin >> s; tr.insert(0, s, 0); } int m; cin >> m; for(int i{}; i < m; i++){ string s; cin >> s; tr.insert(1, s, 0); } cout << (tr.dfs(0) == 0 ? "Nina" : "Emilija"); } int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int t = 1; while(t--){ solve(); } return 0; }

Compilation message (stderr)

Main.cpp: In member function 'void Trie::insert(int, std::string&, int)':
Main.cpp:31:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |         if (pos != sz(s)) c[s[pos]].insert(cur, s, pos+1);
      |                 ^
Main.cpp: In function 'void setio(std::string)':
Main.cpp:19:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |     freopen((s + ".in").c_str(),"r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:20:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |     freopen((s + ".out").c_str(),"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...