# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
897724 | mihtriii295 | Vlak (COCI20_vlak) | C++17 | 7 ms | 11016 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define el cout << '\n'
#define TIME (1.0 * clock() / CLOCKS_PER_SEC)
/* Code by Nguyen Minh Tri (mihtriii) 12TT THPT Chuyen Ben Tre */
const ll N = 3e5 + 1;
ll n, m;
struct Node{
Node *child[26];
int cnt;
bool fn;
Node(){
fn = 0;
cnt = 0;
memset(child, 0, sizeof(child));
}
};
Node *root = new Node();
void Add(string s){
int timer = 0;
Node *p = root;
for (char c : s){
if (p -> child[c - 'a'] == 0 && c){
p -> child[c - 'a'] = new Node();
}
p = p -> child[c - 'a'];
p -> cnt = ++timer;
}
p -> fn = 1;
}
bool Querry(string s){
int timer = 0;
Node *p = root;
for (char c : s){
++timer;
if (p -> child[c - 'a'] == 0){
if (timer & 1) return 0;
else return 1;
}
p = p -> child[c - 'a'];
if (p -> fn) return 1;
}
return 1;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
if (fopen("coci2021_r3_vlak.inp", "r")){
freopen("coci2021_r3_vlak.inp", "r", stdin);
freopen("coci2021_r3_vlak.out", "w", stdout);
}
cin >> n;
for (int i = 1; i <= n; ++i){
string s;
cin >> s;
Add(s);
}
bool ok = 0;
cin >> m;
for (int i = 1; i <= m; ++i){
string s;
cin >> s;
if (Querry(s) == 0){
ok = 1;
break;
}
}
if (ok)
cout << "Nina";
else
cout << "Emilija";
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |