답안 #880739

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
880739 2023-11-30T00:48:16 Z Ahmed_Solyman Vlak (COCI20_vlak) C++14
0 / 70
18 ms 22612 KB
#include <bits/stdc++.h>
#include <ext/rope>
 
using namespace std;
using namespace __gnu_cxx;
#pragma GCC optimize("-Ofast")
#pragma GCC optimize("-O1")
//-------------------------------------------------------------//
typedef long long ll;
typedef unsigned long long ull;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI acos(-1)
#define lb lower_bound
#define ub upper_bound
#define endl '\n'
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define sum_to(n) (n*(n+1))/2
#define pb push_back
#define pf push_front
#define fil(arr,x) memset(arr,x,sizeof(arr))
const ll mod=1e9+7;
int dx[8]={0,1,0,-1,1,1,-1,-1};
int dy[8]={1,0,-1,0,1,-1,-1,1};
//-------------------------------------------------------------//
ll lcm(ll a,ll b)
{
    return (max(a,b)/__gcd(a,b))*min(a,b);
}
void person_bool(bool x)
{
    cout<<(x?"YES":"NO")<<endl;
}
struct node{
    node *a[26];
    int stop[3];
};
node *New(){
    node *ret=new node;
    for(int i=0;i<26;i++){
        ret->a[i]=NULL;
    }
    ret->stop[1]=ret->stop[2]=0;
    return ret;
}
void insert(node *root,string s,int typ){
    node *temp=root;
    for(int i=0;i<(int)s.size();i++){
        if(temp->a[s[i]-'a']==NULL){
            temp->a[s[i]-'a']=New();
        }
        temp=temp->a[s[i]-'a'];
    }
    temp->stop[typ]=1;
}
void build(node *node){
    for(int i=0;i<26;i++){
        if(node->a[i]==NULL){
            continue;
        }
        build(node->a[i]);
        for(int j=1;j<=2;j++){
            node->stop[j] |= node->a[i]->stop[j];
        }
    }
}
int dp[200005];
int solve(node *node,int i){
    int &ret=dp[i];
    if(~ret)return ret;
    if(i%2==0){
        ret=0;
        for(int j=0;j<26;j++){
            if(node->a[j]==NULL){
                continue;
            }
            if(node->a[j]->stop[1]){
                ret|=solve(node->a[j],i+1);
            }
        }
        return ret;
    }
    else{
        ret=0;
        for(int j=0;j<26;j++){
            if(node->a[j]==NULL){
                continue;
            }
            if(node->a[j]->stop[2]){
                ret|=!solve(node->a[j],i+1);
            }
        }
        ret ^= 1;
        return ret;
    }
}
int main()
{
    //freopen("input.in","r",stdin);
    //freopen("output.out","w",stdout);
    fast
    node *root=New();
    int n,m;
    cin>>n;
    for(int i=0;i<n;i++){
        string s;cin>>s;
        insert(root,s,1);
    }
    cin>>m;
    for(int i=0;i<m;i++){
        string s;cin>>s;
        insert(root,s,2);
    }
    build(root);
    fil(dp,-1);
    cout<<(solve(root,0)?"Nina":"Emilija")<<endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 1372 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 1372 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1372 KB Output is correct
2 Correct 1 ms 1372 KB Output is correct
3 Correct 1 ms 1372 KB Output is correct
4 Incorrect 1 ms 1372 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1368 KB Output is correct
2 Incorrect 1 ms 1368 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 17 ms 21084 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 21596 KB Output is correct
2 Correct 16 ms 22612 KB Output is correct
3 Correct 14 ms 20828 KB Output is correct
4 Incorrect 15 ms 21084 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 20428 KB Output is correct
2 Correct 15 ms 19804 KB Output is correct
3 Correct 18 ms 20312 KB Output is correct
4 Incorrect 17 ms 21596 KB Output isn't correct
5 Halted 0 ms 0 KB -