답안 #445951

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
445951 2021-07-20T08:49:49 Z Jasiekstrz Vlak (COCI20_vlak) C++17
70 / 70
27 ms 14380 KB
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
const int N=2e5;
int k=1;
map<char,int> e[N+10];
bool ok[N+10][2];
void add(int x,string::iterator bg,string::iterator en,bool c)
{
	ok[x][c]=true;
	if(bg==en)
		return;
	if(e[x].find(*bg)==e[x].end())
		e[x][*bg]=++k;
	add(e[x][*bg],bg+1,en,c);
	return;
}
bool dfs(int x,bool t)
{
	if(!ok[x][0])
		return 1;
	if(!ok[x][1])
		return 0;
	if(e[x].empty())
		return !t;
	bool vis[2]={0,0};
	for(auto [c,v]:e[x])
		vis[dfs(v,!t)]=true;
	if(!vis[0])
		return 1;
	if(!vis[1])
		return 0;
	return t;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,m;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		string s;
		cin>>s;
		add(1,s.begin(),s.end(),0);
	}
	cin>>m;
	for(int i=1;i<=m;i++)
	{
		string s;
		cin>>s;
		add(1,s.begin(),s.end(),1);
	}
	cout<<(!dfs(1,0) ? "Nina":"Emilija")<<"\n";
	return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9676 KB Output is correct
2 Correct 5 ms 9676 KB Output is correct
3 Correct 6 ms 9804 KB Output is correct
4 Correct 6 ms 9676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9676 KB Output is correct
2 Correct 5 ms 9716 KB Output is correct
3 Correct 6 ms 9708 KB Output is correct
4 Correct 6 ms 9676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9688 KB Output is correct
2 Correct 6 ms 9676 KB Output is correct
3 Correct 6 ms 9688 KB Output is correct
4 Correct 5 ms 9656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 9676 KB Output is correct
2 Correct 5 ms 9676 KB Output is correct
3 Correct 6 ms 9676 KB Output is correct
4 Correct 6 ms 9676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 14072 KB Output is correct
2 Correct 20 ms 13804 KB Output is correct
3 Correct 18 ms 13512 KB Output is correct
4 Correct 21 ms 13856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 14092 KB Output is correct
2 Correct 17 ms 14380 KB Output is correct
3 Correct 15 ms 13940 KB Output is correct
4 Correct 16 ms 14164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 13872 KB Output is correct
2 Correct 17 ms 13816 KB Output is correct
3 Correct 17 ms 13932 KB Output is correct
4 Correct 20 ms 14172 KB Output is correct