# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1101207 |
2024-10-15T18:01:34 Z |
SriniV |
Vlak (COCI20_vlak) |
C++14 |
|
82 ms |
82044 KB |
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//typedef __int128 lll;
#define PI 3.14159265358979323846
#define sbits(x) __builtin_popcountll(x)
#define tbits(total_size, num) ((total_size) - __builtin_clz(num))
#define pb push_back
#define f first
#define s second
#define clr(ds) ds.clear()
#define all(ds) ds.begin(), ds.end()
#define pi pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vpi vector<pi>
#define sz(i) (int)i.size()
using namespace std;
int xP[] = {0,0,1,-1,1,1,-1,-1} , yP[] = {1,-1,0,0,1,-1,-1,1};
uint64_t time() {
using namespace std::chrono;
return duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();
}
int rand(int a , int b){
return a + rand()%(b-a+1);
}
void setIO(string name = "") {
cin.tie(0)->sync_with_stdio(0);
if (name.size()) {
freopen((name + ".in").c_str(), "r", stdin);
freopen((name + ".out").c_str(), "w", stdout);
}
}
bool ckmin(auto& a , auto b){if(a<=b)return 0; else {a=b;return 1;}}
bool ckmax(auto& a , auto b){if(a>=b)return 0; else {a=b;return 1;}}
/*
_______________________________________
( If you don't fail at least 90% of the )
( time, you're not aiming high enough. )
( )
( - Alan Kay )
---------------------------------------
o ^__^
o (oo)\_______
(__)\ )\/\
||----w |
|| ||
*/
const int MAXN = 4e5+1;
struct trie{
int tree[MAXN][26];
int p;
trie(){p = 1;}
void add(string& temp){
int curr = 0;
for(int i = 0;i<sz(temp);i++){
if(tree[curr][temp[i]-97])
curr = tree[curr][temp[i]-97];
else
curr = tree[curr][temp[i]-97] = p++;
}
}
};
int dfs(trie& a , trie& b , int pA , int pB , bool turn){
for(int i =0;i<26;i++){
// a has a character b doesnt
if(turn == 0 && a.tree[pA][i]){
if(!b.tree[pB][i])
return 0;
if(dfs(a , b , a.tree[pA][i], b.tree[pB][i] , 1)==0)
return 0;
} else if(turn && b.tree[pB][i]){
if(!a.tree[pA][i])
return 1;
if(dfs(a , b , a.tree[pA][i] , b.tree[pB][i] , 0))
return 1;
}
}
return 1^turn;
}
int n, m;
void solve(){
trie a , b;
cin >> n;
for(int i= 0;i<n;i++){
string temp;
cin >> temp;
a.add(temp);
}
cin >> m;
for(int i = 0;i<m;i++){
string temp;
cin >> temp;
b.add(temp);
}
cout << (dfs(a , b , 0 , 0 , 0)?"Emilija":"Nina") << "\n";
}
int main(){
setIO();
int t = 1;
// cin >> t;
while(t--){
solve();
}
}
Compilation message
Main.cpp:35:12: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
35 | bool ckmin(auto& a , auto b){if(a<=b)return 0; else {a=b;return 1;}}
| ^~~~
Main.cpp:35:22: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
35 | bool ckmin(auto& a , auto b){if(a<=b)return 0; else {a=b;return 1;}}
| ^~~~
Main.cpp:36:12: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
36 | bool ckmax(auto& a , auto b){if(a>=b)return 0; else {a=b;return 1;}}
| ^~~~
Main.cpp:36:22: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
36 | bool ckmax(auto& a , auto b){if(a>=b)return 0; else {a=b;return 1;}}
| ^~~~
Main.cpp: In function 'void setIO(std::string)':
Main.cpp:31:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
31 | freopen((name + ".in").c_str(), "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:32:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
32 | freopen((name + ".out").c_str(), "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
64 ms |
81736 KB |
Output is correct |
2 |
Correct |
65 ms |
81708 KB |
Output is correct |
3 |
Correct |
62 ms |
81840 KB |
Output is correct |
4 |
Correct |
66 ms |
81664 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
69 ms |
81736 KB |
Output is correct |
2 |
Correct |
63 ms |
81736 KB |
Output is correct |
3 |
Correct |
65 ms |
81644 KB |
Output is correct |
4 |
Correct |
64 ms |
81632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
62 ms |
81736 KB |
Output is correct |
2 |
Correct |
66 ms |
81736 KB |
Output is correct |
3 |
Correct |
65 ms |
81744 KB |
Output is correct |
4 |
Correct |
71 ms |
81748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
77 ms |
81648 KB |
Output is correct |
2 |
Correct |
65 ms |
81764 KB |
Output is correct |
3 |
Correct |
64 ms |
81736 KB |
Output is correct |
4 |
Correct |
65 ms |
81736 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
67 ms |
81736 KB |
Output is correct |
2 |
Correct |
75 ms |
81896 KB |
Output is correct |
3 |
Correct |
68 ms |
82004 KB |
Output is correct |
4 |
Correct |
66 ms |
82044 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
65 ms |
81736 KB |
Output is correct |
2 |
Correct |
66 ms |
81824 KB |
Output is correct |
3 |
Correct |
67 ms |
81996 KB |
Output is correct |
4 |
Correct |
82 ms |
81996 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
67 ms |
81736 KB |
Output is correct |
2 |
Correct |
65 ms |
82004 KB |
Output is correct |
3 |
Correct |
68 ms |
81996 KB |
Output is correct |
4 |
Correct |
66 ms |
81948 KB |
Output is correct |