Submission #1083525

#TimeUsernameProblemLanguageResultExecution timeMemory
1083525HaciyevAlikVlak (COCI20_vlak)C++14
70 / 70
21 ms27740 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define oo 1000000000000000 const int mx = 1e6 + 5; int trie[mx][26]; int last; int dp[mx]; vector<int> mark; void insert(string s,bool turn) { int cur = 0; for(int i = 0; i < s.size(); ++i) { if(!trie[cur][s[i]-'a']) { trie[cur][s[i]-'a'] = ++last; } cur = trie[cur][s[i]-'a']; } if(mark[cur] == -1) { mark[cur] = turn; } else { mark[cur] = (mark[cur] != turn ? 2 : mark[cur]); } } void dfs(int u,int lvl) { if(lvl % 2) { dp[u] = 1; } else { dp[u] = 2; } bool check = false; for(int i = 0; i < 26; ++i) { if(trie[u][i]) { dfs(trie[u][i],lvl + 1); check = 1; if(lvl%2) dp[u] = max(dp[u],dp[trie[u][i]]); else dp[u] = min(dp[u],dp[trie[u][i]]); } } if(!check) { if(mark[u] == 2) { if(lvl%2) dp[u] = 1; else dp[u] = 2; } else { dp[u] = mark[u] + 1; } } } signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); mark.assign(mx, -1); int n; cin >> n; for(int i = 1; i <= n; ++i) { string s; cin >> s; insert(s,0); } int m; cin >> m; for(int i = 1; i <= m; ++i) { string s; cin >> s; insert(s,1); } dfs(0,0); if(dp[0] == 1) { cout << "Nina"; } else { cout << "Emilija"; } return 0; }

Compilation message (stderr)

Main.cpp: In function 'void insert(std::string, bool)':
Main.cpp:14:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |  for(int i = 0; i < s.size(); ++i) {
      |                 ~~^~~~~~~~~~
#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...