# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
994153 |
2024-06-07T07:44:01 Z |
KawakiMeido |
Vlak (COCI20_vlak) |
C++17 |
|
21 ms |
20572 KB |
/*Author: KawakiMeido*/
#include <bits/stdc++.h>
#define pb push_back
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define fi first
#define se second
using namespace std;
/*Constants*/
const int N = 2e5+10;
const int INF = 1e9+7;
const long long LLINF = 1e18+3;
/*TestCases*/
int test=1;
void solve();
void TestCases(bool v){
if (v) cin >> test;
while(test--) solve();
}
/*Global Variables*/
int n,m;
//Trie
struct Trie{
struct Node{
bool reach[2];
Node* child[26];
Node(){
for (int i=0; i<26; i++) child[i] = NULL;
reach[0] = reach[1] = 0;
}
};
Node* Root;
Trie(){
Root = new Node();
Root->reach[0] = Root->reach[1] = 1;
}
void AddString(string s, int id){
Node* cur = Root;
for (auto f:s){
int idx = f-'a';
if (cur->child[idx] == NULL) cur->child[idx] = new Node();
cur = cur->child[idx];
cur -> reach[id] = true;
}
}
bool Magic(int pos, Node* cur, string &s){
if (!(cur->reach[pos%2])) return 0;
bool res = true;
// cout << s << " " << res << " " << pos << endl;
for (int i=0; i<26; i++){
if (cur->child[i]!=NULL){
// cout << s << " " << res << " " << pos << endl;
s += char('a'+i);
res = (res && !(Magic(pos+1,cur->child[i],s)));
s.pop_back();
}
}
// cout << s << " " << pos << " " << res << endl;
// cout << s << " " << res << " " << pos << endl;
return res;
}
bool Solve(){
bool ans = 0;
string s;
for (int i=0; i<26; i++){
if (Root->child[i]!=NULL){
s += char('a'+i);
ans = (Magic(0,Root->child[i],s) || ans);
s.pop_back();
}
}
return ans;
}
};
Trie TR;
/*Solution*/
void solve(){
cin >> n;
string s;
for (int i=1; i<=n; i++){
cin >> s;
TR.AddString(s,0);
}
cin >> m;
for (int i=1; i<=m; i++){
cin >> s;
TR.AddString(s,1);
}
if (TR.Solve()){
cout << "Nina" << endl;
}
else cout << "Emilija" << endl;
}
/*Driver Code*/
signed main(){
// ios_base::sync_with_stdio(0);
// cin.tie(0);
TestCases(0);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
604 KB |
Output is correct |
2 |
Correct |
0 ms |
604 KB |
Output is correct |
3 |
Correct |
0 ms |
604 KB |
Output is correct |
4 |
Correct |
1 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 |
604 KB |
Output is correct |
3 |
Correct |
0 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
604 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 |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
604 KB |
Output is correct |
2 |
Correct |
0 ms |
604 KB |
Output is correct |
3 |
Correct |
0 ms |
436 KB |
Output is correct |
4 |
Correct |
1 ms |
600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
19028 KB |
Output is correct |
2 |
Correct |
16 ms |
18012 KB |
Output is correct |
3 |
Correct |
14 ms |
16988 KB |
Output is correct |
4 |
Correct |
17 ms |
18612 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
19548 KB |
Output is correct |
2 |
Correct |
18 ms |
20572 KB |
Output is correct |
3 |
Correct |
14 ms |
18780 KB |
Output is correct |
4 |
Correct |
18 ms |
19156 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
18524 KB |
Output is correct |
2 |
Correct |
15 ms |
18012 KB |
Output is correct |
3 |
Correct |
15 ms |
18524 KB |
Output is correct |
4 |
Correct |
15 ms |
19548 KB |
Output is correct |