답안 #1011698

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1011698 2024-07-01T06:39:37 Z vjudge1 Vlak (COCI20_vlak) C++17
70 / 70
13 ms 10076 KB
#include <bits/stdc++.h>

using namespace std;

const int M = 2e5 + 1;

int nxt[M][26],cnt=1;
bool rc[M][2],win[M][2];

void add(string s,int i)
{
	int cur=0;
	for (char c:s)
	{
		if (!nxt[cur][c-'a'])
			nxt[cur][c-'a']=cnt++;
		rc[cur][i]=1;
		cur=nxt[cur][c-'a'];
	}
	rc[cur][i]=1;
}

void dfs(int u)
{
	for (int i=0;i<26;i++)
	{
		if (!nxt[u][i])
			continue;
		int v=nxt[u][i];
		dfs(v);
		for (int pl=0;pl<2;pl++)
		{
			if (rc[v][pl] && !win[v][1-pl])
				win[u][pl]=1;
		}
	}
}

int main()
{
	for (int j=0;j<2;j++)
	{
		int n;
		cin>>n;
		for (int i=0;i<n;i++)
		{
			string s;
			cin>>s;
			add(s,j);
		}
	}
	dfs(0);
	if (win[0][0])
		cout<<"Nina"<<endl;
	else
		cout<<"Emilija"<<endl;
	
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 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 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 444 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 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 13 ms 9564 KB Output is correct
2 Correct 11 ms 9040 KB Output is correct
3 Correct 12 ms 8540 KB Output is correct
4 Correct 10 ms 9308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 9820 KB Output is correct
2 Correct 11 ms 10076 KB Output is correct
3 Correct 10 ms 9308 KB Output is correct
4 Correct 9 ms 9388 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 9304 KB Output is correct
2 Correct 11 ms 9052 KB Output is correct
3 Correct 12 ms 9340 KB Output is correct
4 Correct 11 ms 9820 KB Output is correct