Submission #563605

#TimeUsernameProblemLanguageResultExecution timeMemory
563605IwanttobreakfreeVlak (COCI20_vlak)C++98
70 / 70
66 ms25432 KiB
#include <iostream> #include <vector> #include <map> using namespace std; struct cell{ map<char,int> nina,emi,word; }; vector<cell> trie; void add_nina(string& s){ int u=0; for(int i=0;i<s.size();i++){ if(trie[u].word.find(s[i])==trie[u].word.end()){ trie[u].word[s[i]]=trie.size(); map<char,int> a,b,c; trie.push_back({a,b,c}); } trie[u].nina[s[i]]=trie[u].word[s[i]], u=trie[u].nina[s[i]]; } } void add_emi(string& s){ int u=0; for(int i=0;i<s.size();i++){ if(trie[u].word.find(s[i])==trie[u].word.end()){ trie[u].word[s[i]]=trie.size(); map<char,int> a,b,c; trie.push_back({a,b,c}); } trie[u].emi[s[i]]=trie[u].word[s[i]]; u=trie[u].emi[s[i]]; } } int ok(int u,int turn){ //si encuentra un camino por el que el otro pierde if(turn){ for(auto x:trie[u].nina){ if(!ok(x.second,1-turn))return 1; } } else{ for(auto x:trie[u].emi){ if(!ok(x.second,1-turn))return 1; } } return 0; } int main(){ map<char,int> a,b,c; trie.push_back({a,b,c}); int n; string s; cin>>n; while(n--){ cin>>s; add_nina(s); } cin>>n; while(n--){ cin>>s; add_emi(s); } if(ok(0,1))cout<<"Nina"; else cout<<"Emilija"; }

Compilation message (stderr)

Main.cpp: In function 'void add_nina(std::string&)':
Main.cpp:11:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for(int i=0;i<s.size();i++){
      |                 ~^~~~~~~~~
Main.cpp: In function 'void add_emi(std::string&)':
Main.cpp:23:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for(int i=0;i<s.size();i++){
      |                 ~^~~~~~~~~
#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...