Submission #378883

# Submission time Handle Problem Language Result Execution time Memory
378883 2021-03-17T06:57:27 Z topovik Vlak (COCI20_vlak) C++14
70 / 70
23 ms 14804 KB
#include <bits/stdc++.h>
#define in(x) freopen(x, "r", stdin)
#define out(x) freopen(x, "w", stdout)
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-O3")
#define F first
#define S second
#define pb push_back
//#define M ll(1e9 + 7)
#define sz(x) (int)x.size()
#define re return
#define oo ll(1e18)
#define el '\n'
#define pii pair <int, int>
#define all(x) (x).begin(), (x).end()
#define arr_all(x, n) (x + 1), (x + 1 + n)
#define vi vector<int>
#define pb push_back
#define len(x) (int)x.size()
using namespace std;
//using namespace __gnu_pbds;
//typedef tree <int, null_type, less_equal <int> , rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = 1e6;

vector <int*> bor;
vector <int*> kol;

int dp[N];

void create_new_vertex()
{
    bor.pb(NULL);
    bor.back() = (int*)calloc(sizeof(int), 26);
    kol.pb(NULL);
    kol.back() = (int*)calloc(sizeof(int), 2);
}

string cur;

void Add(int nom)
{
    int x = 0;
    kol[0][nom]++;
    for (int i = 0; i < cur.size(); i++)
    {
        int y = cur[i] - 'a';
        if (bor[x][y] == 0) bor[x][y] = len(bor), create_new_vertex();
        x = bor[x][y];
        kol[x][nom]++;
    }
}

int Rec(int x, int par)
{
    bool g = 0;
    for (int i = 0; i < 26; i++)
        if (bor[x][i] != 0 && kol[bor[x][i]][par] > 0) g = g || (!Rec(bor[x][i], par ^ 1));
    return g;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	create_new_vertex();
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
    {
        cin >> cur;
        Add(0);
    }
    int m;
    cin >> m;
    for (int i = 0; i < m; i++)
    {
        cin >> cur;
        Add(1);
    }

    cout << (Rec(0, 0) ? "Nina" : "Emilija");
}

Compilation message

Main.cpp: In function 'void Add(int)':
Main.cpp:51:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |     for (int i = 0; i < cur.size(); i++)
      |                     ~~^~~~~~~~~~~~
# Verdict Execution time Memory 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 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 620 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 13908 KB Output is correct
2 Correct 20 ms 13012 KB Output is correct
3 Correct 20 ms 12272 KB Output is correct
4 Correct 23 ms 13524 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 14164 KB Output is correct
2 Correct 20 ms 14804 KB Output is correct
3 Correct 18 ms 13652 KB Output is correct
4 Correct 18 ms 13908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 13416 KB Output is correct
2 Correct 18 ms 13012 KB Output is correct
3 Correct 20 ms 13396 KB Output is correct
4 Correct 20 ms 14292 KB Output is correct