답안 #595710

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
595710 2022-07-14T02:25:16 Z tht2005 Vlak (COCI20_vlak) C++17
70 / 70
12 ms 9812 KB
#include <bits/stdc++.h>

using namespace std;

int rd() {
    bool neg = 0; char c = getchar(); for(; c < '0' || c > '9'; c = getchar()) if(c == '-') neg = !neg;
    int n = 0; while('0' <= c && c <= '9') n = (n << 3) + (n << 1) + c - '0', c = getchar();
    return neg ? -n : n;
}
void wr(int n) {
    static char o[11];
    if(n < 0) putchar('-'), n = -n;
    int i = 0; do o[i++] = n % 10 + '0'; while(n /= 10);
    while(i--) putchar(o[i]);
}

#define L 200005
#define V ((N) * (L))

int cnt = 1, nxt[L][26];
bool lf[2][L];
char s[L];

bool f(int v, int t) {
    for(int i = 26, u; i--; ) {
        u = nxt[v][i];
        if(u == 0 || !lf[t][u]) {
            continue;
        }
        if(!f(u, t ^ 1)) {
            return 1;
        }
    }
    return 0;
}

int main() {
    for(int t = 0; t < 2; ++t) {
        int n;
        scanf("%d", &n);
        for(int i = 0, l, p; i < n; ++i) {
            scanf("%s", s);
            l = strlen(s);
            p = 0;
            for(int j = 0, e; j < l; ++j) {
                e = s[j] - 'a';
                if(nxt[p][e] == 0) {
                    nxt[p][e] = cnt++;
                }
                p = nxt[p][e];
                lf[t][p] = 1;
            }
        }
    }
    puts(f(0, 0) ? "Nina" : "Emilija");
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:40:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |         scanf("%d", &n);
      |         ~~~~~^~~~~~~~~~
Main.cpp:42:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |             scanf("%s", s);
      |             ~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 440 KB Output is correct
3 Correct 1 ms 432 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 9300 KB Output is correct
2 Correct 9 ms 8628 KB Output is correct
3 Correct 7 ms 8276 KB Output is correct
4 Correct 12 ms 9184 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 9460 KB Output is correct
2 Correct 8 ms 9812 KB Output is correct
3 Correct 7 ms 9044 KB Output is correct
4 Correct 8 ms 9300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 8916 KB Output is correct
2 Correct 8 ms 8784 KB Output is correct
3 Correct 8 ms 9000 KB Output is correct
4 Correct 9 ms 9540 KB Output is correct