| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1361027 | trandkhoa | Vlak (COCI20_vlak) | C++20 | 21 ms | 34524 KiB |
/**
* Author: Tran Dang Khoa
**/
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#define ll long long
#define FOR(i,l,r) for(int i = (l), _r = (r); i <= _r; i++)
#define FORN(i,r,l) for(int i = (r), _l = (l); i >= _l; i--)
#define MASK(x) (1LL << (x))
#define BIT(x,i) (((x) >> (i)) & 1)
#define sz(x) (int)x.size()
#define all(v) (v).begin(),(v).end()
#define segleft (id << 1)
#define segright (id << 1 | 1)
#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
const int MOD = 1e9+7;
void iofile(string s) {
freopen((s + ".inp").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}
const int N = 2e5 + 5;
struct TrieDS {
struct Node {
int child[27];
Node() { fill(child, child + 27, -1); }
};
vector<Node> Trie;
TrieDS() {
Trie.push_back(Node()); // 0 (dummy)
Trie.push_back(Node()); // 1 (root)
}
int create_node() {
Trie.push_back(Node());
return sz(Trie) - 1;
}
void insert_string(const string &s) {
int p = 1;
for (char c : s) {
int id = c - 'a' + 1;
if (Trie[p].child[id] == -1) {
Trie[p].child[id] = create_node();
}
p = Trie[p].child[id];
}
}
};
void trandkhoa() {
TrieDS Nina, Emilija;
int n; cin >> n;
vector<string> Nina_str(n + 1);
FOR(i, 1, n) {
string word; cin >> word;
Nina.insert_string(word);
Nina_str[i] = word;
}
int m; cin >> m;
vector<string> Emilija_str(m + 1);
FOR(i, 1, m) {
string word; cin >> word;
Emilija.insert_string(word);
Emilija_str[i] = word;
}
bool flag = false;
FOR(i, 1, n) {
string word = Nina_str[i];
int pNina = 1, pEmilija = 1;
FOR(j, 1, sz(word)) {
int c = word[j - 1] - 'a' + 1;
if (j & 1) {
if (Emilija.Trie[pEmilija].child[c] == -1) {
flag = true;
break;
}
pNina = Nina.Trie[pNina].child[c];
pEmilija = Emilija.Trie[pEmilija].child[c];
bool check = false;
FOR(t, 1, 26) {
if (Emilija.Trie[pEmilija].child[t] != -1) check = true;
}
if (!check) {
flag = true;
break;
}
} else {
bool check = false;
FOR(t, 1, 26) {
if (Emilija.Trie[pEmilija].child[t] != -1 && Nina.Trie[pNina].child[t] == -1) check = true;
}
if (check) break;
if (Nina.Trie[pNina].child[c] != -1 && Emilija.Trie[pEmilija].child[c] != -1) {
pNina = Nina.Trie[pNina].child[c];
pEmilija = Emilija.Trie[pEmilija].child[c];
} else {
break;
}
}
}
if (flag) break;
}
if (flag) {
cout << "Nina" << endl;
} else {
cout << "Emilija" << endl;
}
}
signed main() {
ios_base::sync_with_stdio(0); cin.tie(0);
//iofile("");
int test = 1;
//cin >> test;
while(test--) trandkhoa();
return (0 ^ 0);
}Compilation message (stderr)
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
