답안 #1004164

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1004164 2024-06-21T06:00:44 Z NoLove Vlak (COCI20_vlak) C++14
60 / 70
14 ms 19728 KB
/**
 *    author : Lăng Trọng Đạt
 *    created: 21-06-2024 
**/
#include <bits/stdc++.h>
using namespace std;
#ifndef LANG_DAT
#define db(...) ;
#endif // LANG_DAT
#define int long long
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define all(v) (v).begin(), (v).end()
using pii = pair<int, int>;
using vi = vector<int>;
#define FOR(i, a, b) for (int (i) = a; (i) <= (b); i++)
void mx(int& a, int b) { if (b > a) a = b; }
void mi(int& a, int b) { if (b < a) a = b; }
#define si(x) (int)(x.size())
const int INF = 1e18;
const int MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;
bitset<MAXN> dp, nina, em;
int d[MAXN];
int nxt[MAXN][26];
int n, m, sz = 0;
string s, t;

void insert(string& s, bool Nina = true) {
    int v = 0;
    for (char c : s) {
        (Nina ? nina[v] = 0 : em[v] = 0);
        
        if (!nxt[v][c - 'a']) nxt[v][c - 'a'] = ++sz;
        d[nxt[v][c - 'a']] = d[v] + 1;
        v = nxt[v][c - 'a'];
    }
    (Nina ? nina[v] = 1 : em[v] = 1);
}

bool dfs(int v, int h) {
    db(v, h)
    bool res1 = false, res2 = false;
    if (nina[v] && !em[v]) return false;
    else if (!nina[v] && em[v]) return true;
    else if (nina[v] && em[v]) return h % 2 == 1;

    FOR(i, 0, 25) 
        if (nxt[v][i]) {
            bool tmp = dfs(nxt[v][i], h + 1);
            (tmp ? res1 = 1 : res2 = 1);
        }
    if (h % 2 == 1) {
        return !res2;
    } else return res1;
}

int32_t main() {
    cin.tie(0)->sync_with_stdio(0);
    if (fopen("hi.inp", "r")) {
        freopen("hi.inp", "r", stdin);
//        freopen("hi.out", "w", stdout);
    } 

    nina.flip();
    em.flip();
    cin >> n;
    FOR(i, 1, n) {
        cin >> s;
        insert(s);
    }
    cin >> m;
    FOR(i, 1, m) {
        cin >> t;
        insert(t, 0);
    }
    db(sz)
    cout << (dfs(0, 0) ? "Nina" : "Emilija");
}

Compilation message

Main.cpp: In function 'bool dfs(long long int, long long int)':
Main.cpp:18:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   18 | #define FOR(i, a, b) for (int (i) = a; (i) <= (b); i++)
      |                               ^
Main.cpp:51:5: note: in expansion of macro 'FOR'
   51 |     FOR(i, 0, 25)
      |     ^~~
Main.cpp: In function 'int32_t main()':
Main.cpp:18:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   18 | #define FOR(i, a, b) for (int (i) = a; (i) <= (b); i++)
      |                               ^
Main.cpp:71:5: note: in expansion of macro 'FOR'
   71 |     FOR(i, 1, n) {
      |     ^~~
Main.cpp:18:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   18 | #define FOR(i, a, b) for (int (i) = a; (i) <= (b); i++)
      |                               ^
Main.cpp:76:5: note: in expansion of macro 'FOR'
   76 |     FOR(i, 1, m) {
      |     ^~~
Main.cpp:64:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   64 |         freopen("hi.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 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 0 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 0 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 18612 KB Output is correct
2 Correct 10 ms 17452 KB Output is correct
3 Correct 9 ms 16476 KB Output is correct
4 Correct 13 ms 18012 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 19036 KB Output is correct
2 Correct 14 ms 19728 KB Output is correct
3 Incorrect 10 ms 18248 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 18008 KB Output is correct
2 Correct 11 ms 17612 KB Output is correct
3 Correct 11 ms 17948 KB Output is correct
4 Correct 12 ms 19032 KB Output is correct