답안 #377400

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
377400 2021-03-14T07:03:29 Z ne4eHbKa Vlak (COCI20_vlak) C++17
70 / 70
28 ms 20332 KB
#include <bits/stdc++.h>
using namespace std;
#ifndef _LOCAL
//#pragma GCC optimize("O3,Ofast")
#else
#pragma GCC optimize("O0")
#endif
template<typename t> inline void umin(t &a, const t b) {a = min(a, b);}
template<typename t> inline void umax(t &a, const t b) {a = max(a, b);}
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
typedef int8_t byte;
ll time() {return chrono::system_clock().now().time_since_epoch().count();}
mt19937 rnd(time());
#define ft first
#define sd second
#define len(f) int((f).size())
#define bnd(f) (f).begin(), (f).end()
#define _ <<' '<<
const int inf = 1e9 + 5;
const ll inf64 = 4e18 + 5;
const int md = 998244353;
namespace MD {
    void add(int &a, const int b) {if((a += b) >= md) a -= md;}
    void sub(int &a, const int b) {if((a -= b) < 0) a += md;}
    int prod(const int a, const int b) {return ll(a) * b % md;}
};

const int A = 26;

struct b {
    b* nx[A] {};
    bool d[2] {}, v {};
    void add(char *c, int n, int p) {
        d[p] = true;
        if(!n) return;
        auto &j = nx[*c - 'a'];
        if(!j) j = new b();
        j->add(c + 1, n - 1, p);
    }
    void game(int move = 0) {
        v = move ^ 1;
        for(int i = 0; i < A; ++i) {
            if(!nx[i]) continue;
            nx[i]->game(move ^ 1);
            if(nx[i]->v == move && nx[i]->d[move])
                v = move;
        }
    }
};

void solve() {
    b t {};
    int n;
    cin >> n; while(n--) {string f; cin >> f; t.add(&f[0], len(f), 0);}
    cin >> n; while(n--) {string f; cin >> f; t.add(&f[0], len(f), 1);}
    t.game();
    cout << (t.v ? "Emilija\n" : "Nina\n");
}

signed main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#ifndef _LOCAL
//    freopen("file.in", "r", stdin);
//    freopen("file.out", "w", stdout);
#else
    system("color a");
    freopen("in.txt", "r", stdin);
    int t; cin >> t;
    while(t--)
#endif
    solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 620 KB Output is correct
2 Correct 1 ms 620 KB Output is correct
3 Correct 1 ms 620 KB Output is correct
4 Correct 1 ms 620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 620 KB Output is correct
2 Correct 1 ms 620 KB Output is correct
3 Correct 1 ms 620 KB Output is correct
4 Correct 1 ms 620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 620 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 1 ms 620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 1 ms 768 KB Output is correct
3 Correct 1 ms 620 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 18924 KB Output is correct
2 Correct 27 ms 17772 KB Output is correct
3 Correct 23 ms 16748 KB Output is correct
4 Correct 25 ms 18540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 19436 KB Output is correct
2 Correct 24 ms 20332 KB Output is correct
3 Correct 24 ms 18668 KB Output is correct
4 Correct 22 ms 18924 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 18284 KB Output is correct
2 Correct 24 ms 17920 KB Output is correct
3 Correct 24 ms 18412 KB Output is correct
4 Correct 24 ms 19564 KB Output is correct