# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1092710 | 2024-09-24T19:32:01 Z | vjudge1 | Vlak (COCI20_vlak) | C++17 | 1000 ms | 348 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=0; struct trienode { trienode* child[26]; bool wordEnd; bool player=0; ll cur_node; trienode() { wordEnd=false; for(auto &it:child)it= nullptr; } }; 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->player= play; cur=cur->child[it-'a']; cur->cur_node=node++; } 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=dp[i][player]; if(ret!=-1)return ret; ret=player; for(int j=0;j<25;j++) { if(cur->child[j]!= nullptr&&cur->child[j]->player!=player) { if(player) ret=min(ret, solve(cur->child[j]->cur_node,!player,cur->child[j])); else 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); } ll ans=0; memset(dp,-1, sizeof dp); for(int i=0;i<=25;i++) { if(trie.root->child[i]!= nullptr) ans=max(ans, solve(trie.root->child[i]->cur_node,1,trie.root->child[i])); } if(ans) cout<<"Nina"<<endl; else cout<<"Emilija"<<endl; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1040 ms | 344 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1050 ms | 344 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1070 ms | 348 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1077 ms | 348 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1067 ms | 348 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1068 ms | 348 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1046 ms | 344 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |