# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
844759 |
2023-09-05T20:00:19 Z |
vjudge1 |
Vlak (COCI20_vlak) |
C++17 |
|
15 ms |
22616 KB |
#include <bits/stdc++.h>
#pragma optimize "DostSeferoğlu"
#pragma GCC optimize("unroll-loops,Ofast")
#pragma GCC target("avx2,tune=native")
using namespace std;
#define int long long
#define pii pair<int,int>
#define bg begin
#define vi vector<int>
#define endl '\n'
#define vvi vector<vi>
#define vp vector<pii>
#define sp << " " <<
#define all(x) x.bg()+1,x.end()
#define ff first
#define ss second
#define brake {cout << "OK\n";return;}
#define debug(x) {cout << #x << ": "; for (auto it : x) cout << it << " ";cout << endl;}
#define FF(xxx,sss,yyy) for (int xxx=sss;xxx<=yyy;++xxx)
#define F(xx,yy) for (int xx=1;xx<=yy;++xx)
#define pb push_back
const int inf = 1e18;
const int MOD = 998244353;
const int N = 2e5+1;
struct Node {
Node* children[26];
Node() {
for (int i = 0; i < 26; ++i) children[i] = NULL;
}
};
void add(Node* root,string s) {
int ptr = 0;
int n = s.size();
while (ptr < n) {
if (root->children[s[ptr]-'a'] != NULL) {
root = root->children[s[ptr]-'a'];
}
else {
root->children[s[ptr]-'a'] = new Node();
root = root->children[s[ptr]-'a'];
}
ptr++;
}
}
bool win(Node* trie1,Node*trie2) {
for (int i=0;i<26;i++){
if (trie1->children[i] != NULL && trie2->children[i]==NULL) {
return true;
}
}
bool wins = false;
for (int i=0;i<26;i++) {
if (trie1->children[i] != NULL) {
wins = max(wins,!win(trie2->children[i],trie1->children[i]));
}
}
return wins;
}
void solve() {
int n;
cin >> n;
Node *trie1 = new Node();
Node *trie2 = new Node();
for (int i=1;i<=n;i++) {
string s;
cin >> s;
add(trie1,s);
}
int m;
cin >> m;
for (int i=1;i<=m;i++) {
string s;
cin >> s;
add(trie2,s);
}
if (win(trie1,trie2)) {
cout << "Nina\n";
}
else cout << "Emilija\n";
}
signed main() {
ios_base::sync_with_stdio(0);cin.tie(0);
#ifdef Local
freopen("input.in", "r", stdin);
freopen("input.out", "w", stdout);
#endif
int t = 1;
//cin >> t;
while (t --> 0) solve();
}
Compilation message
Main.cpp:2: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
2 | #pragma optimize "DostSeferoğlu"
|
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
856 KB |
Output is correct |
3 |
Correct |
0 ms |
600 KB |
Output is correct |
4 |
Correct |
0 ms |
600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
604 KB |
Output is correct |
2 |
Correct |
1 ms |
600 KB |
Output is correct |
3 |
Correct |
0 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
600 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
600 KB |
Output is correct |
3 |
Correct |
1 ms |
600 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
21080 KB |
Output is correct |
2 |
Correct |
13 ms |
19800 KB |
Output is correct |
3 |
Correct |
12 ms |
18776 KB |
Output is correct |
4 |
Correct |
13 ms |
20568 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
21592 KB |
Output is correct |
2 |
Correct |
14 ms |
22616 KB |
Output is correct |
3 |
Correct |
13 ms |
20824 KB |
Output is correct |
4 |
Correct |
13 ms |
21080 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
20312 KB |
Output is correct |
2 |
Correct |
12 ms |
19800 KB |
Output is correct |
3 |
Correct |
13 ms |
20312 KB |
Output is correct |
4 |
Correct |
14 ms |
21852 KB |
Output is correct |