# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
692251 | Huy | Vlak (COCI20_vlak) | C++17 | 43 ms | 29420 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define fi first
#define se second
#pragma GCC tarGet ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC tarGet("avx,avx2,fma")
using namespace std;
using ll = long long;
const int mod = 1e9+7;
const int maxN = 3e5+5;
const int N = 3e5;
const ll infty = 1e16;
void InputFile()
{
freopen("CONC.inp","r",stdin);
freopen("CONC.out","w",stdout);
//freopen("test.out","r",stdin);
}
int n,m;
struct TNode
{
int child[26];
int type;
int depth;
};
vector<TNode> Tree;
int dp[maxN];
void add_node()
{
TNode tmp;
for(int i = 0;i < 26;i++)
{
tmp.child[i] = -1;
}
tmp.type = 0;
tmp.depth = 0;
Tree.push_back(tmp);
}
void Insert(string s,int p)
{
int it = 0;
for(int i = 0;i < s.size();i++)
{
if(Tree[it].child[s[i]-'a'] == -1)
{
add_node();
Tree[it].child[s[i]-'a'] = Tree.size() - 1;
}
int fa = it;
it = Tree[it].child[s[i]-'a'];
Tree[it].type |= p;
Tree[it].depth = (Tree[fa].depth + 1) % 2;
}
}
void DP(int u)
{
for(int i = 0;i < 26;i++)
{
if(Tree[u].child[i] == -1) continue;
int v = Tree[u].child[i];
if(Tree[v].type & (1 << Tree[u].depth))
{
DP(v);
dp[u] = max(dp[u],dp[v] ^ 1);
}
}
}
void Read()
{
add_node();
cin >> n;
for(int i = 1;i <= n;i++)
{
string s;
cin >> s;
Insert(s,1);
}
cin >> m;
for(int i = 1;i <= m;i++)
{
string s;
cin >> s;
Insert(s,2);
}
DP(0);
if(dp[0])
{
cout <<"Nina";
return;
}
cout <<"Emilija";
}
void Solve()
{
}
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
//InputFile();
//int sub_type;
//cin >> sub_type;
//Sieve();
//Prepare();
int test;
//cin >> test;
test = 1;
while(test--)
//for(int prc = 1; prc <= test; prc++)
{
Read();
Solve();
//Debug();
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |