답안 #838798

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
838798 2023-08-27T18:40:59 Z kingmessi Vlak (COCI20_vlak) C++17
70 / 70
15 ms 19156 KB
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define repin rep(i,0,n)
#define di(a) int a;cin>>a;
#define precise(i) cout<<fixed<<setprecision(i)
#define vi vector<int>
#define si set<int>
#define mii map<int,int>
#define take(a,n) for(int j=0;j<n;j++) cin>>a[j];
#define give(a,n) for(int j=0;j<n;j++) cout<<a[j]<<' ';
#define vpii vector<pair<int,int>>
#define sis string s;
#define sin string s;cin>>s;
#define db double
#define be(x) x.begin(),x.end()
#define pii pair<int,int>
#define pb push_back
#define pob pop_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bpc(x) __builtin_popcountll(x) 
#define btz(x) __builtin_ctz(x)
using namespace std;

using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<pair<int, int>, null_type,less<pair<int, int> >, rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;

const long long INF=1e18;
const long long M=1e9+7;
const long long MM=998244353;
  
int power( int N, int M){
    int power = N, sum = 1;
    if(N == 0) sum = 0;
    while(M > 0){if((M & 1) == 1){sum *= power;}
    power = power * power;M = M >> 1;}
    return sum;
}

const int SZ= 5000005;
int nex[SZ][26], num = 0;
bool pos[SZ][2];
void ins(string &s,int f) {
    int cur = 0;
    pos[cur][f]=true;
    int n = s.length();
    repin {
        if (!nex[cur][s[i]-'a']) nex[cur][s[i]-'a'] = ++num;
        cur = nex[cur][s[i]-'a'];
        pos[cur][f]=true;
    }
}

bool dfs(int cur,int turn){
    if(!pos[cur][turn])return false;
    bool ans = 1;
    rep(i,0,26){
        if(nex[cur][i]){
            ans&=dfs(nex[cur][i],1-turn);
        }
    }
    return 1-ans;
}

 
void solve()
{
    int n;
    cin>>n;
    repin{
        string s;
        cin>>s;
        ins(s,0);
    }
    int m;
    cin>>m;
    rep(i,0,m){
        string s;
        cin>>s;
        ins(s,1);
    }
    int result = dfs(0,0);
    if(result)cout<<"Nina\n";
    else cout<<"Emilija\n";
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef NCR
        init();
    #endif
    #ifdef SIEVE
        sieve();
    #endif
        solve();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 0 ms 596 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 580 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 18004 KB Output is correct
2 Correct 14 ms 16808 KB Output is correct
3 Correct 14 ms 15956 KB Output is correct
4 Correct 14 ms 17492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 18388 KB Output is correct
2 Correct 13 ms 19156 KB Output is correct
3 Correct 13 ms 17620 KB Output is correct
4 Correct 13 ms 18004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 17364 KB Output is correct
2 Correct 13 ms 16932 KB Output is correct
3 Correct 14 ms 17324 KB Output is correct
4 Correct 15 ms 18388 KB Output is correct