답안 #974312

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
974312 2024-05-03T08:15:39 Z PieArmy Vlak (COCI20_vlak) C++17
70 / 70
8 ms 10076 KB
#include <bits/stdc++.h>
using namespace std;

int trie[200001][26];
bool var[200001][2];
int las=1;

void ekle(string word,int player){
    int pos=0;
    for(char c:word){
        if(!trie[pos][c-'a']){
            trie[pos][c-'a']=las++;
        }
        pos=trie[pos][c-'a'];
        var[pos][player]=1;
    }
}

bool dfs(int pos,int sira){
    for(int i=0;i<26;i++){
        if(!trie[pos][i])continue;
        if(!var[trie[pos][i]][sira])continue;
        if(dfs(trie[pos][i],sira^1)==sira)return sira;
    }
    return sira^1;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	int n;cin>>n;
    for(int i=0;i<n;i++){
        string s;cin>>s;
        ekle(s,0);
    }
    cin>>n;
    for(int i=0;i<n;i++){
        string s;cin>>s;
        ekle(s,1);
    }
    if(dfs(0,0))cout<<"Emilija";
    else cout<<"Nina";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 464 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 9436 KB Output is correct
2 Correct 7 ms 8796 KB Output is correct
3 Correct 7 ms 8284 KB Output is correct
4 Correct 7 ms 9048 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 9564 KB Output is correct
2 Correct 7 ms 10076 KB Output is correct
3 Correct 7 ms 9308 KB Output is correct
4 Correct 7 ms 9304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 9048 KB Output is correct
2 Correct 6 ms 8924 KB Output is correct
3 Correct 6 ms 9052 KB Output is correct
4 Correct 8 ms 9660 KB Output is correct