답안 #563605

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
563605 2022-05-17T16:55:49 Z Iwanttobreakfree Vlak (COCI20_vlak) C++
70 / 70
66 ms 25432 KB
#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

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++){
      |                 ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 724 KB Output is correct
2 Correct 2 ms 724 KB Output is correct
3 Correct 1 ms 724 KB Output is correct
4 Correct 1 ms 684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 724 KB Output is correct
2 Correct 1 ms 724 KB Output is correct
3 Correct 1 ms 724 KB Output is correct
4 Correct 1 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 724 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 724 KB Output is correct
3 Correct 1 ms 724 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 25360 KB Output is correct
2 Correct 48 ms 25404 KB Output is correct
3 Correct 48 ms 25344 KB Output is correct
4 Correct 66 ms 25432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 25340 KB Output is correct
2 Correct 39 ms 25284 KB Output is correct
3 Correct 39 ms 25400 KB Output is correct
4 Correct 52 ms 25400 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 41 ms 25372 KB Output is correct
2 Correct 41 ms 25372 KB Output is correct
3 Correct 42 ms 25368 KB Output is correct
4 Correct 47 ms 25384 KB Output is correct