| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1312880 | raymoo_ | Vlak (COCI20_vlak) | C++17 | 14 ms | 14416 KiB |
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pii pair<int, int>
#define bend(v) v.begin(),v.end()
#define vect vector
#define prq priority_queue
#define umap unordered_map
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define ef emplace_front
#define pf push_front
#define pof pop_front
#define el "\n"
#define deb cout<<"\nok\n";return
#define nextl cout<<"\n"
#define lwb lower_bound
#define upb upper_bound
#define rs resize
#define popcnt __builtin_popcount
#define clz __builtin_clz
#define ctz __builtin_ctz
#define ll long long
#define dbl long double
#define int long long
#define FILE "ijustwannabepartofyourskibidi"
void IO(){
if(fopen(FILE".in", "r")){
freopen(FILE".in", "r", stdin);
freopen(FILE".out", "w", stdout);
}
else if(fopen(FILE".inp", "r")){
freopen(FILE".inp", "r", stdin);
freopen(FILE".out", "w", stdout);
}
}
const ll N = 3e5 + 1, MOD = 1e9+7, INF = 1000000000000000069;
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
ll rand(ll l, ll r){
return uniform_int_distribution<ll>(l, r)(rng);
}
ll pm(ll a,const ll b=MOD){return ((a%b)+b)%b;}
ll sq(ll x){return x*x;}
ll __lcm(ll a, ll b, const ll lim=LLONG_MAX){
if(a == -1 || b == -1)return -1;
ll g = __gcd(a,b);
if(b/g > lim/a)return -1;
return (a/g)*b;
}
struct node{
int nxt[26];
char val;
bool blocked, subtree_blocked;
node(char v = 0){
val = v;
blocked = 0;
subtree_blocked = 0;
memset(nxt, -1, sizeof nxt);
}
};
struct Trie{
vect<node> t;
Trie(){
t.pb(node(-1));
}
void add(const string &s){
int p = 0;
for(char c : s){
if(t[p].nxt[c - 'a'] != -1) p = t[p].nxt[c - 'a'];
else{
t[p].nxt[c - 'a'] = t.size();
p = t.size();
t.pb(node(c));
}
}
}
void emilija(const string& s){
int p = 0;
vect<int> path;
for(int i=0; s.size() > i; i++){
path.eb(p);
if(t[p].nxt[s[i] - 'a'] == -1){
// cout << s << ' ' << i << el;
// for(int j : path) cout << j << ' ';
// nextl;
// cout << p << ' ' << i << el;
t[p].blocked = i & 1;
return;
}else p = t[p].nxt[s[i] - 'a'];
}
}
void dfs1(int u, int dep){
int available = 26 - count(t[u].nxt, t[u].nxt + 26, -1);
t[u].subtree_blocked = t[u].blocked;
int cnt = 0;
for(int i=0; 26>i; i++){
if(t[u].nxt[i] != -1){
dfs1(t[u].nxt[i], dep + 1);
cnt += t[t[u].nxt[i]].subtree_blocked;
}
}
t[u].subtree_blocked |= cnt == available && available;
if(dep & 1 && cnt) t[u].subtree_blocked = 1;
// cout << u << ' ' << t[u].subtree_blocked << ' ' << t[u].val << ' ' << available << ' ' << cnt << el;
}
void dfs2(int u, int dep){
int available = 26 - count(t[u].nxt, t[u].nxt + 26, -1);
if(available == 0){
cout << "Nina";
exit(0);
}
if(dep % 2 == 1){
for(int i=0; 26>i; i++){
if(t[u].nxt[i] != -1 && t[t[u].nxt[i]].subtree_blocked){
return;
}
}
}
for(int i=0; 26>i; i++){
if(t[u].nxt[i] != -1 && !t[t[u].nxt[i]].blocked){
dfs2(t[u].nxt[i], dep+1);
}
}
}
};
void sol(){
int n;
cin >> n;
Trie trie;
for(int i=0; n>i; i++){
string s;
cin >> s;
if(s.size() % 2 == 0) s.pob();
trie.add(s);
}
int m;
cin >> m;
for(int i=0; m>i;i++){
string s;
cin >> s;
trie.emilija(s);
}
trie.dfs1(0, 0);
trie.dfs2(0, 0);
cout << "Emilija";
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(NULL);cout.tie(NULL);
IO();
int t = 1;
// cin >> t;
while(t--) sol();
}
/*
...-%%%%%%%%%%%...
.:**#%=%%%%%+........-%%%%. .
.%%%%%%=-..%#. .#%%.
%%%+.. .: *%%.
.%%. :. :%%%%%:.
.%%. ... .: :: .=%%%.
..%%. #%#:%. : :.. =%%.
%%+..: .%*::::%-::::::-::::::.. .:-%%%%. .*%%..
.%# :.%:::::::%%%%%%%%%%%%%+...%%%+::::%#. .%%.
.%%. ..:.%=::::*%#***#%::::::::%%%%=:::::::%%. .%%.
=%%%...-%%%:::*%********%:::%%%****%::::::::%% .%-
.%::::%%***%=:%%**********%%********%:::::::=%-:. .%..
#%:::%#*****%%**********************%:::+%%%*%%-.: .::..%%.
.%%::%%*****==**==*****#************#%%%%#******%%..::::.. .%%.
.%%#%+%%***************##*+=+*==********************%%.:. .%%
.%%***%%****************#**==**==******==**+=+********%%%%%%%%% %%.
.#%#*********************%%**************++************%%::::::%* .%%%.
.%%***************#*****%%%****************************%%::::::%% .-%%%.
.#%***************#****%%--%*********%*****************%#::::-%%%%%%%%%%.
.%%**************#**%%%----%********%%**************#***#%%%#**%#******%*
.%%**************#%%%--.....%%*******%%**************#**********#%******%%.
.%%*************%%...........%%******%-%*************#***********%%*****%%.
.%%*************%%...%%%%%.....%%%%%%%.=%%%%%%%%##****#****##::::+%%*****%#
.%%************%%...%. %%.................%%%%-.....%*****#*****%%*****%%
.#%#*#****#****%%:::%- %%.................%. #-....%*****#*#####%#****%%.
.%%##****%%%**%%:::::##...................%= .%+:::%#*****#:####*%%****%%.
.+%%#**%%.#%%%%::::::........###+.:*##-....%%%:::::%*****##******%%****%%-
..%%*%%.......:::.......##..#*...#+..#*....:::::%******#*****##%%*****%%.
.%%%%%................#-##=--##+-+###-#....:::%******#:###*::%%#*****%%.
.%%****%%..............#----------------=*...#%#****##**##::#**%%*******%%.
.%%%%%*=+%%*...........#-----------------#.....#%%%%%%+:##*##:*%%*******%%%.
..:*%====%%%%........#-----------------#:.........%#********%%*****%%%%%%.
.%%=======*%%%%%%%.%%+----#-%------%%#.......%%%%::::::::%%==***#%###%%.
..%%=============+%%-:#%%%%-::%%%%%%::%%%%%%%%%=%%*******%%=====**%%###%%..
-%%%%%%%%%%%%%%%%+%.%+:+%::%::::%::%:::%%#%... .%%******%%%========#%####%%.
.%%++#############%%# ..%%.**%%#%%%%%%%#%***%. :%%*****%%%=+%%%%%%%%%%#####%%.
.%%++++*############*++% .%************#****%. #%*%%%%+++%%%%###############%%.
.+%%%%%%%%%%####+##########*+++++%%. .%**#**********#****% %%**%%%++++###################%:
=%%%%######################++++++++%%*%.-%%#***********#****% .%****%%+++++###################%%
.%%%#######################*%%%%%%%%.%%*#%+%###################%.%%***%%%+++++###################%%
*%%######################+#%%++++++%*. =%*%. .:%%%%########%%%%%%%%%#*#%.%%++#####################%%
.%%%#####################%%%%%+++++++%- %*#%%. .%%%*++++++*%%%....%%#####################%%*
%%######%%%%%#%%%%%######%%.%*+++++++%. %****#. .%%+++*+++++*++%%...=%%###################%%%.
%%%%%%%%#-=##%...%%######%%.%%+++++++%%..*%***#%%%%%. ..%+++++++++++++++%%...%%##################%%%.
.%:. .#%#####%%.%%+++++++++%. %*********%%%%%++++++++++++++++%%...%%##############%%%%..
:%#####%% .%%+++++++%% .%%**********%%++++++++++++++++%%.....%#########%%%%%% .
*%#####%%. .%%+++++++%%:. .%%********%%++++++++++++++++%%....%%%%%%%%%%%%*..
.%%##%%% .%%*+++++++%%. ..#%%%#****%%+++++++++++++++%%%%%% . .....
%%#%%%. .:%%%%%%%%%%%...-%. ......%%+++++++++++++%%.
..%%%. ... .%%%#%%%=:#%%%%%%%%*++++++%%%#
.-%%+. ... .%%%%%%%:.
*/
컴파일 시 표준 에러 (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... | ||||
