# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1092716 | 2024-09-24T19:55:07 Z | vjudge1 | Vlak (COCI20_vlak) | C++17 | 23 ms | 25088 KB |
// #pragma GCC optimize ("O3") // #pragma GCC optimize ("unroll-loops") // #pragma comment(linker, "/STACK:2000000") #include<bits/stdc++.h> using namespace std; #define ll long long #define int long long #define ld long double #define endl "\n" #define FOCUS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); void Go() { ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr); #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif } ll node=1; struct trienode { trienode* child[26]; bool wordEnd; bool player1=0; bool player2=0; ll cur_node; trienode() { wordEnd=false; for(auto &it:child)it= nullptr; cur_node=0; } }; struct Trie { trienode* root=new trienode(); void insert(string s,bool play) { trienode* cur=root; for(auto it:s) { if(cur->child[it-'a']== nullptr) cur->child[it-'a']=new trienode (),cur->child[it-'a']->cur_node=node++; if(play)cur->child[it-'a']->player2=1; else cur->child[it-'a']->player1=1; cur=cur->child[it-'a']; } cur->wordEnd=true; } bool search(string s) { trienode*cur=root; for(auto it:s) { if(cur->child[it-'a']== nullptr)return false; cur=cur->child[it-'a']; } return cur->wordEnd; } }; int dp[(int)2e5+1][2]; ll solve(ll i,bool player,trienode* cur) { ll ret=player; for(int j=0;j<25;j++) { if(cur->child[j]!= nullptr) { if(player&&cur->child[j]->player2) { if(!cur->child[j]->player1)return 0; ret = min(ret, solve(cur->child[j]->cur_node, !player, cur->child[j])); } else if(cur->child[j]->player1&&!player) { if(!cur->child[j]->player2)return 1; ret = max(ret, solve(cur->child[j]->cur_node, !player, cur->child[j])); } } } return ret; } signed main() { //Go(); Trie trie; int n; cin>>n; for(int i=0;i<n;i++) { string s; cin>>s; trie.insert(s,0); } int m; cin>>m; for(int i=0;i<m;i++) { string s; cin>>s; trie.insert(s,1); } memset(dp,-1, sizeof dp); if(solve(trie.root->cur_node,0,trie.root)) cout<<"Nina"<<endl; else cout<<"Emilija"<<endl; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 3672 KB | Output is correct |
2 | Correct | 2 ms | 3676 KB | Output is correct |
3 | Correct | 2 ms | 3676 KB | Output is correct |
4 | Correct | 1 ms | 3676 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 3676 KB | Output is correct |
2 | Correct | 1 ms | 3676 KB | Output is correct |
3 | Correct | 1 ms | 3676 KB | Output is correct |
4 | Correct | 2 ms | 3676 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 3676 KB | Output is correct |
2 | Correct | 2 ms | 3676 KB | Output is correct |
3 | Correct | 2 ms | 3676 KB | Output is correct |
4 | Correct | 1 ms | 3676 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 3676 KB | Output is correct |
2 | Correct | 1 ms | 3676 KB | Output is correct |
3 | Correct | 2 ms | 3676 KB | Output is correct |
4 | Correct | 1 ms | 3676 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 23644 KB | Output is correct |
2 | Correct | 17 ms | 22364 KB | Output is correct |
3 | Correct | 16 ms | 21340 KB | Output is correct |
4 | Correct | 23 ms | 23064 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 22 ms | 24156 KB | Output is correct |
2 | Correct | 17 ms | 25088 KB | Output is correct |
3 | Correct | 16 ms | 23240 KB | Output is correct |
4 | Correct | 20 ms | 23644 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 21 ms | 23000 KB | Output is correct |
2 | Correct | 16 ms | 22376 KB | Output is correct |
3 | Correct | 17 ms | 22888 KB | Output is correct |
4 | Correct | 19 ms | 24168 KB | Output is correct |