Submission #1015908

#TimeUsernameProblemLanguageResultExecution timeMemory
1015908vjudge1Vlak (COCI20_vlak)C++17
70 / 70
14 ms15680 KiB
#pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt") #define _GLIBCXX_FILESYSTEM #include<bits/stdc++.h> using namespace std; #define ll long long struct Trie{ struct node{ int nxt[26]; node(){ memset(nxt,-1,sizeof(nxt)); } }; vector<node> trie; Trie(){ trie.emplace_back(); } void insert(string &s){ int cur = 0; for(int i = 0; i < s.size(); i++){ if(trie[cur].nxt[s[i]-'a'] == -1){ trie[cur].nxt[s[i]-'a'] = trie.size(); trie.push_back(node()); } cur = trie[cur].nxt[s[i]-'a']; } } }; Trie nina,emil; int dfs(int i,int j,int cur){ for(int k = 0; k < 26; k++){ if(cur){ if(emil.trie[j].nxt[k] != -1 and nina.trie[i].nxt[k] == -1) return 1; } else{ if(nina.trie[i].nxt[k] != -1 and emil.trie[j].nxt[k] == -1) return 1; } } vector<bool> mex(27,0); for(int k = 0; k < 26; k++){ if(emil.trie[j].nxt[k] != -1 and nina.trie[i].nxt[k] != -1){ int now = dfs(nina.trie[i].nxt[k],emil.trie[j].nxt[k],cur^1); if(now < 27) mex[now] = 1; } } for(int k = 0; k < 27; k++){ if(!mex[k]) return k; } } void solve() { int n; cin >> n; for(int i = 0; i < n; i++){ string s; cin >> s; nina.insert(s); } int m; cin >> m; for(int i = 0; i < m; i++){ string s; cin >> s; emil.insert(s); } if(dfs(0,0,0)) cout << "Nina\n"; else cout << "Emilija\n"; return; } int32_t main() { ios_base::sync_with_stdio(false);cin.tie(NULL); int tc = 1; // cin >> tc; for(int kase = 1; kase <= tc; kase++) { //cout << "Case " << kase << ": "; solve(); } return 0; }

Compilation message (stderr)

Main.cpp: In member function 'void Trie::insert(std::string&)':
Main.cpp:22:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |         for(int i = 0; i < s.size(); i++){
      |                        ~~^~~~~~~~~~
Main.cpp: In function 'int dfs(int, int, int)':
Main.cpp:42:26: warning: control reaches end of non-void function [-Wreturn-type]
   42 |     vector<bool> mex(27,0);
      |                          ^
#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...