답안 #881055

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
881055 2023-11-30T12:29:59 Z HossamHero7 Vlak (COCI20_vlak) C++14
70 / 70
8 ms 22872 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
const int N = 200005;
int tree[N][26];
bool player[N][2];
int dp[N][2];
int pt = 1;
void add(string s,bool b){
    int node = 0;
    for(int i=0;i<s.size();i++){
        if(~tree[node][s[i]-'a']) {
            node = tree[node][s[i]-'a'];
            player[node][b] = 1;
        }
        else {
            tree[node][s[i]-'a'] = pt ++;
            node = tree[node][s[i]-'a'];
            player[node][b] = 1;
        }
    }
}
int solve(int node,bool b){
    if(!player[node][b]) return 0;
    int &ret = dp[node][b];
    if(~ret) return ret;
    ret = 0;
    for(int c=0;c<26;c++){
        if((~tree[node][c]) && player[tree[node][c]][b]){
            ret |= !solve(tree[node][c],!b);
        }
    }
    return ret;
}
void solve(){
    int n;
    cin>>n;
    memset(tree,-1,sizeof(tree));
    while(n--){
        string s;
        cin>>s;
        add(s,0);
    }
    cin>>n;
    while(n--){
        string s;
        cin>>s;
        add(s,1);
    }
    memset(dp,-1,sizeof(dp));
    player[0][0] = player[0][1] = 1;
    cout<<(solve(0,0) ? "Nina" : "Emilija")<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);      cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Compilation message

Main.cpp: In function 'void add(std::string, bool)':
Main.cpp:12:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     for(int i=0;i<s.size();i++){
      |                 ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 22620 KB Output is correct
2 Correct 4 ms 22620 KB Output is correct
3 Correct 4 ms 22620 KB Output is correct
4 Correct 4 ms 22616 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 22872 KB Output is correct
2 Correct 4 ms 22620 KB Output is correct
3 Correct 4 ms 22620 KB Output is correct
4 Correct 4 ms 22620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 22616 KB Output is correct
2 Correct 4 ms 22620 KB Output is correct
3 Correct 4 ms 22872 KB Output is correct
4 Correct 4 ms 22620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 22620 KB Output is correct
2 Correct 5 ms 22620 KB Output is correct
3 Correct 4 ms 22620 KB Output is correct
4 Correct 4 ms 22872 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 22616 KB Output is correct
2 Correct 7 ms 22872 KB Output is correct
3 Correct 7 ms 22620 KB Output is correct
4 Correct 7 ms 22520 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 22620 KB Output is correct
2 Correct 7 ms 22592 KB Output is correct
3 Correct 7 ms 22620 KB Output is correct
4 Correct 7 ms 22620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 22620 KB Output is correct
2 Correct 7 ms 22620 KB Output is correct
3 Correct 8 ms 22620 KB Output is correct
4 Correct 8 ms 22592 KB Output is correct