답안 #753213

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
753213 2023-06-04T20:12:50 Z MilosMilutinovic Vlak (COCI20_vlak) C++14
70 / 70
15 ms 9936 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
const int M = 20 * N;
const int A = 26;
int n, m, tsz, ch[M][A];
bool has[M][2];
char str[N];
void ins(int x) {
    int nd = 0;
    for (int i = 1; i <= strlen(str + 1); i++) {
        int c = (int) (str[i] - 'a');
        if (!ch[nd][c])
            ch[nd][c] = ++tsz;
        nd = ch[nd][c];
        has[nd][x] = true;
    }
}
bool solve(int nd, int player) {
    bool win = false;
    for (int i = 0; i < A; i++) {
        if (!ch[nd][i])
            continue;
        if (has[ch[nd][i]][player]) {
            win = (win | !solve(ch[nd][i], player ^ 1));
        }
    }
    return win;
}
int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%s", str + 1);
        ins(0);
    }
    scanf("%d", &m);
    for (int i = 1; i <= m; i++) {
        scanf("%s", str + 1);
        ins(1);
    }
    if (solve(0, 0))
        printf("Nina\n");
    else
        printf("Emilija\n");
    return 0;
}
/*
2
aaa
bbb
3
aab
aba
bbb
*/

Compilation message

Main.cpp: In function 'void ins(int)':
Main.cpp:11:23: warning: comparison of integer expressions of different signedness: 'int' and 'size_t' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for (int i = 1; i <= strlen(str + 1); i++) {
      |                     ~~^~~~~~~~~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:31:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
Main.cpp:33:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |         scanf("%s", str + 1);
      |         ~~~~~^~~~~~~~~~~~~~~
Main.cpp:36:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |     scanf("%d", &m);
      |     ~~~~~^~~~~~~~~~
Main.cpp:38:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |         scanf("%s", str + 1);
      |         ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 308 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 436 KB Output is correct
4 Correct 1 ms 416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 9336 KB Output is correct
2 Correct 12 ms 8660 KB Output is correct
3 Correct 9 ms 8248 KB Output is correct
4 Correct 10 ms 9020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 9428 KB Output is correct
2 Correct 10 ms 9936 KB Output is correct
3 Correct 9 ms 9076 KB Output is correct
4 Correct 10 ms 9272 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 8992 KB Output is correct
2 Correct 10 ms 8788 KB Output is correct
3 Correct 10 ms 9048 KB Output is correct
4 Correct 12 ms 9532 KB Output is correct