# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
689922 |
2023-01-29T18:50:01 Z |
gagik_2007 |
Vlak (COCI20_vlak) |
C++17 |
|
20 ms |
14656 KB |
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <chrono>
#include <ctime>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <limits>
#include <iomanip>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <functional>
#include <random>
#include <cassert>
using namespace std;
typedef long long ll;
typedef long double ld;
#define ff first
#define ss second
const int K = 26;
class Vertex {
public:
bool f, s, fw, sw;
int to[K];
Vertex() {
f = s = false;
fw = sw = false;
fill(to, to + K, -1);
}
};
ll ttt;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const ll N = 1000007;
ll n, m, k;
vector<Vertex>p(1);
void add_f(const string& s) {
int v = 0;
for (char ch : s) {
p[v].fw = true;
int c = ch - 'a';
if (p[v].to[c] == -1) {
p[v].to[c] = p.size();
p.emplace_back();
}
v = p[v].to[c];
}
p[v].fw = true;
}
void add_s(const string& s) {
int v = 0;
for (char ch : s) {
p[v].sw = true;
int c = ch - 'a';
if (p[v].to[c] == -1) {
p[v].to[c] = p.size();
p.emplace_back();
}
v = p[v].to[c];
}
p[v].sw = true;
}
void calc(int v) {
for (int i = 0; i < K; i++) {
int to = p[v].to[i];
if (to != -1) {
if (p[to].fw && !p[to].s) {
p[v].f = true;
}
if (p[to].sw && !p[to].f) {
p[v].s = true;
}
}
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
string s;
for (int i = 0; i < n; i++) {
cin >> s;
add_f(s);
}
cin >> m;
for (int i = 0; i < m; i++) {
cin >> s;
add_s(s);
}
//cout << "HASAV" << endl;
for (int i = p.size() - 1; i >= 0; i--) {
calc(i);
}
if (p[0].f) {
cout << "Nina" << endl;
}
else {
cout << "Emilija" << endl;
}
return 0;
}
/// ---- - -------- ------ -------- -- - - -
/// Just a reminder. Ubuntu password is I O I
/// ---- - -------- ------ -------- -- - - -
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
596 KB |
Output is correct |
2 |
Correct |
1 ms |
576 KB |
Output is correct |
3 |
Correct |
1 ms |
596 KB |
Output is correct |
4 |
Correct |
1 ms |
572 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
596 KB |
Output is correct |
2 |
Correct |
1 ms |
572 KB |
Output is correct |
3 |
Correct |
1 ms |
596 KB |
Output is correct |
4 |
Correct |
1 ms |
576 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
596 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
448 KB |
Output is correct |
2 |
Correct |
1 ms |
596 KB |
Output is correct |
3 |
Correct |
1 ms |
596 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
14496 KB |
Output is correct |
2 |
Correct |
17 ms |
14540 KB |
Output is correct |
3 |
Correct |
20 ms |
14512 KB |
Output is correct |
4 |
Correct |
17 ms |
14520 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
14492 KB |
Output is correct |
2 |
Correct |
16 ms |
14400 KB |
Output is correct |
3 |
Correct |
18 ms |
14540 KB |
Output is correct |
4 |
Correct |
16 ms |
14528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
14464 KB |
Output is correct |
2 |
Correct |
18 ms |
14508 KB |
Output is correct |
3 |
Correct |
19 ms |
14656 KB |
Output is correct |
4 |
Correct |
17 ms |
14528 KB |
Output is correct |