Submission #472135

# Submission time Handle Problem Language Result Execution time Memory
472135 2021-09-13T06:55:55 Z abc864197532 Vlak (COCI20_vlak) C++17
70 / 70
38 ms 25588 KB
/*
 *   ##   #####   ####      ####  #    #  ####
 *  #  #  #    # #    #    #    # #    # #    #
 * #    # #####  #         #    # #    # #    #
 * ###### #    # #         #    # # ## # #    #
 * #    # #    # #    #    #    # ##  ## #    #
 * #    # #####   ####      ####  #    #  ####
 */
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair <int, int>
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define info() cout << __PRETTY_FUNCTION__ << ": " << __LINE__ << endl
void abc() {cout << endl;}
template <typename T, typename ...U> void abc(T a, U ...b) {
    cout << a << ' ', abc(b...);
}
template <typename T> void printv(T l, T r) {
    while (l != r) cout << *l << " \n"[++l == r];
}
template <typename A, typename B> istream& operator >> (istream& o, pair<A, B> &a) {
    return o >> a.X >> a.Y;
}
template <typename A, typename B> ostream& operator << (ostream& o, pair<A, B> a) {
    return o << '(' << a.X << ", " << a.Y << ')';
}
template <typename T> ostream& operator << (ostream& o, vector<T> a) {
    bool is = false;
    if (a.empty) o << '{';
    for (T i : a) {o << (is ? ' ' : '{'), is = true, o << i;}
    return o << '}';
}
template <typename T> struct vv : vector <vector <T>> {
    vv(int n, int m, T v) : vector <vector <T>> (n, vector <T>(m, v)) {}
    vv() {}
};
template <typename T> struct vvv : vector <vv <T>> {
    vvv(int n, int m, int k, T v) : vector <vv <T>> (n, vv <T>(m, k, v)) {}
    vvv() {}
};
#ifdef Doludu
#define test(args...) info(), abc("[" + string(#args) + "]", args)
#define owo freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#else
#define test(args...) void(0)
#define owo ios::sync_with_stdio(false); cin.tie(0)
#endif
const int mod = 1e9 + 7, N = 200001, logN = 20, K = 80000;

struct trie {
    vector <vector <int>> ch;
    trie() {append();}
    void append() {
        ch.pb(vector <int>(26, 0));
    }
    int get(int u, int c) {
        if (ch[u][c]) return ch[u][c];
        append();
        return ch[u][c] = ch.size() - 1;
    }
} T;

vector <int> adj[2][N];
bool vis[N], dp[N];

bool solve(int v, int d = 0) {
    if (vis[v]) return dp[v];
    vis[v] = true;
    for (int u : adj[d][v]) {
        if (!solve(u, d ^ 1)) return dp[v] = true;
    }
    return dp[v] = false;
} 

int main () {
    owo;
    int n, m;
    cin >> n;
    string s;
    for (int i = 0; i < n; ++i) {
        cin >> s;
        int pre = 0;
        for (int j = 0; j < s.length(); ++j) {
            int nxt = T.get(pre, s[j] - 'a');
            adj[0][pre].pb(nxt);
            pre = nxt;
        }
    }
    cin >> m;
    for (int i = 0; i < m; ++i) {
        cin >> s;
        int pre = 0;
        for (int j = 0; j < s.length(); ++j) {
            int nxt = T.get(pre, s[j] - 'a');
            adj[1][pre].pb(nxt);
            pre = nxt;
        }
    }
    cout << (solve(0) ? "Nina\n" : "Emilija\n");
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:90:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   90 |         for (int j = 0; j < s.length(); ++j) {
      |                         ~~^~~~~~~~~~~~
Main.cpp:100:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  100 |         for (int j = 0; j < s.length(); ++j) {
      |                         ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 9868 KB Output is correct
2 Correct 6 ms 9932 KB Output is correct
3 Correct 6 ms 9804 KB Output is correct
4 Correct 6 ms 9804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 9932 KB Output is correct
2 Correct 7 ms 9932 KB Output is correct
3 Correct 6 ms 9804 KB Output is correct
4 Correct 6 ms 9832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 9804 KB Output is correct
2 Correct 6 ms 9804 KB Output is correct
3 Correct 5 ms 9804 KB Output is correct
4 Correct 6 ms 9804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 9764 KB Output is correct
2 Correct 6 ms 9804 KB Output is correct
3 Correct 6 ms 9804 KB Output is correct
4 Correct 6 ms 9804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 24316 KB Output is correct
2 Correct 30 ms 23408 KB Output is correct
3 Correct 29 ms 22876 KB Output is correct
4 Correct 31 ms 24128 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 24752 KB Output is correct
2 Correct 30 ms 25588 KB Output is correct
3 Correct 31 ms 24512 KB Output is correct
4 Correct 31 ms 24644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 23932 KB Output is correct
2 Correct 38 ms 23716 KB Output is correct
3 Correct 30 ms 24188 KB Output is correct
4 Correct 31 ms 24956 KB Output is correct