제출 #1275997

#제출 시각아이디문제언어결과실행 시간메모리
1275997nitterVlak (COCI20_vlak)C++17
70 / 70
28 ms38756 KiB
/* -----@ @-@ @----#-@ :-#@ @::---- -- :-----@ %::-:--- --: @:----:---@@ @:::::---@ --@ @:- ---:::::::::*@@@ @@:--------- -- ::@ =--::#::::::-------@@ @=::::@@ @----@------@ ::-- @:- @::::::@:::---------@ @@::::-----------@@:------@----- : ::::@-@ @:- @::::----:----:::------- -------------%-------: ::::::-- @:@ ::=---:-@@-----@@-*+- --@ @------*-------::::::::@-@ :-@ :: : :::::-------------@- -*+@------***@---:::::::::-@ :-@:::.:::::::::@-#---------- .************%%@:::.::::-@ @:--::::::::::::-@--------- ++++# ..#**********%%: :::::-= :---:::::::::-@---------@ ..@**********%%%::::%-@@ @---=::::::@---------***. ......*+@%%%%%%%%%%%@. :==@ @---@:::@--------**= :*@....@=*#**:: ::=@ @*@ @---@@-@-----**@ %:-***%::: .:=:%@ @-- +----@----*@ : @ ::::: ::-@%%%%%@ ---- @-@:---@ : . : @@ @ @::-*. :: @@@@ : : :@ @ @::-*@ . :: :=@@@@@ :*:::#:::::::::-:::::- = @ @:--**: : :::@@@@@@@@ : ::***#::*******#:: =++ @:--***::@: **@@@@@@@@@@@::@:::::::@@@@@@@@#**@ .++++@ @:--***%:**: #@@@@@@@@@@@@@@@+::+@@@@@@@@@@@@* ++++++. : ::--****@*:: :@@@-------@@@@@@@@@@@@@@@---@@@ =++++ @+:::::: @---****::-: ::-----#@@----@@@@@@@@@@------- @::::@ ..# @@@@ @---** :+##:: ::@@@@@@@@@@@@@@@@@@@@@@@@@@@ :::@ ..:....:.....:@ @--*@:**####%:: ::@@@@@@@@@@@@@@@@@@@@@@@@@ @ =:::@ @ ..@.......@...@ @-- :*##:::#:::@:::@@@@@@@@@@@@@@@@@@@@@@ =+ ::::@ : ..... ...... +@- **:: :::@@@@@@@@@@@@@@@@@@@@@@@@@ @ :::::::@ .@......... @@ #+:: :..@@@@...@@@@@@@@@@@@ .@@- --@ #::::::: @ @ .......... @ ..@ @:: * .... ...@@@@@@@@ . ....-----+@ @ ::: @ ......... @ ....:::: :@ . ... .. ....@:::@ @-----@ ::::::@ ......... * .....::: @. . ..@@@@....@: @-@ ::::@ . ....... . @@: * .@ :. :. . : @@ :: @@@@@@@@%@. @ ..@ :. @@: @@ @ : -=--+++++++++@ @ . ..@@@%.%: :@ .. @ @@::: @ @ : ------------+++++ @ .+ .@::---*** : :: .. @::: @ @@ . : ---------+++ ** .::::---=** : ::..@@..@ ::::: @ @@@####@@@ :::: -- :---------++ @ - :::::----** : ::..@:: @ @@%%####%@@@ ::: ---------@@------+ @. *. ::-:----**@::::*..#:. @ --@@@@@@@@@@@ :. ------- @-+ . ....... :::-----**:::*@**@ : %%%@@@@@*%%@@ ------++ *+---- @@@@@@@ +:-----**#:#:@**+-@.@ @ %%#+%@***++@@ ------+++++---------- @:---**%#@::@%*-----@ @ @@##+#+@@ -----+------++++++--- @ . :-***%@::.@%%------- ------------------++++ % @....:*#%@: ::**%*-------@ @**@ ------ @----++ + @....@*%- ::@@:*%*-------@ %%@%% -+ @@###@@@ ---- @ @@ @.* := :*=-------- @ @%@@@ --@@*@###@@@@@ @-- : @ :* @*--------= @ --%*@@#@@%@@@@ @- @: @ @ :** @--------*@ +++@@ --@@@@@@@%@@@@ - @: @@@@@@ :** %-------** ++++*+++ --**#@*++*@@@@ - @: @ : :** :@--@------** :::++++++@ @ - -@++++++@@@ @- :: @ ::: :**@ @:: +**-------** :::::+++++ -@%#%%%@ @-- @::: :*** : :: **--------*** :::::-++++@ --@ @---- @::: :: :*** : : @:*--------*--* ::::::-+++ --- -------- @ @ :: : :@: :@ =**---*-------- ..@ :::::::+ +- @ :@ : .:: @***-**------*....+@ @::@ ++-- @ @ :- :: % ::: @:****---------.==%# @: +++-++ :::@ :::@ .:**@-..:*@---**.---@ @ =::: +++++# @ :::::::: :*--..+* ...=@+---@%@ @ :::::::: ++++@ @ @ @@@ :*-....--.+*==.-@%****@ % =@@@@@ #:@= @:***%%..-*=%%%****% .@@ @@............@ %: @ @:****..===%***@+*** ......* @:****@-#*** @ ..... @ @:********+ .... @ @ ::::: @=******** :@@ : :: .:**: **@ ..: ::::@ : @@@.. * ..%::::@ Nitter -.- @@.... @@@ ..: */ #include <bits/stdc++.h> using namespace std; #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() #define pb push_back #define ld_ans(x) fixed << setprecision(x) #define sz(a) int(a.size()) #define F first #define S second typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef long double ld; const int MOD = 1e9+7; const int INF = INT_MAX; const ll INF64 = LLONG_MAX; const long double EPS = 1e-9; const long double PI = acosl(-1.0L); struct Node{ int v; vi who; vector<bool> wins; Node* nxt[26]; Node(int __v){ v = __v; who.assign(26,-1); wins.assign(26,0); for(int i=0;i<26;i++)nxt[i] = NULL; } }; struct Trie{ typedef Node* pnode; pnode root; void insert(string &s,bool w){ pnode cur = root; for(int i=0;i<sz(s);i++){ int b = s[i]-'a'; if(cur->nxt[b]==NULL)cur->nxt[b] = new Node(b); if(cur->who[b]==-1)cur->who[b] = !w; else if(cur->who[b] != !w)cur->who[b] = 2; cur = cur->nxt[b]; } } bool wins(pnode cur,bool turn){ bool win = 0; for(int i=0;i<26;i++){ if(cur->nxt[i]==NULL)continue; if(turn){ if(cur->nxt[i] && cur->who[i]==0)return 1; if(cur->nxt[i] && cur->who[i]==2)cur->wins[i] = !wins(cur->nxt[i],!turn); }else{ if(cur->nxt[i] && cur->who[i]==1)return 1; if(cur->nxt[i] && cur->who[i]==2)cur->wins[i] = !wins(cur->nxt[i],!turn); } } for(int i=0;i<26;i++){ if(cur->nxt[i]){ if(cur->who[i]==2)win |= cur->wins[i]; else if(turn && cur->who[i]==0)win|= cur->wins[i]; else if(cur->who[i]==1)win|= cur->wins[i]; } } return win; } }; void solve(){ Trie t; t.root = new Node('?'); int n;cin >> n; for(int i=0;i<n;i++){ string s; cin >> s; t.insert(s,1); } int m;cin >> m; for(int i=0;i<m;i++){ string s; cin >> s; t.insert(s,0); } cout << (t.wins(t.root,1)?"Nina":"Emilija") << '\n'; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int tc = 1; //cin >> tc; for (int t = 1; t <= tc; t++)solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...