Submission #707228

#TimeUsernameProblemLanguageResultExecution timeMemory
707228Chal1shkanVlak (COCI20_vlak)C++14
70 / 70
14 ms21664 KiB
# include <bits/stdc++.h> # define pb push_back # define ff first # define ss second # define nl "\n" # define sz(x) ((int)(x).size()) # define deb(x) cerr << #x << " = " << x << endl; # define pll pair <ll, ll> typedef long long ll; typedef unsigned long long ull; typedef long double ld; const ll maxn = 2e5 + 25; const ll inf = 2e9 + 0; const ll mod = 1e9 + 123; const ll dx[] = {-1, 1, 0, 0}; const ll dy[] = {0, 0, -1, 1}; using namespace std; struct vertex { int nxt[26]; int mask; vertex () { memset(nxt, -1, sizeof nxt); mask = 0; } }; int n, m; vertex t[maxn]; int nv = 1; void add (string s, int bit) { int v = 0; for (int i = 0; i < sz(s); ++i) { t[v].mask |= (1 << bit); int c = s[i] - 'a'; if (t[v].nxt[c] == -1) { t[v].nxt[c] = nv++; } v = t[v].nxt[c]; } t[v].mask |= (1 << bit); } bool dfs (int v, int turn) { bool ok = 0; for (int c = 0; c < 26; ++c) { ll to = t[v].nxt[c]; if (to == -1) continue; if (t[to].mask & (1LL << turn) && !dfs(to, turn ^ 1)) { return 1; } } return 0; } void ma1n (/* SABR */) { cin >> n; for (int i = 0; i < n; ++i) { string s; cin >> s; add(s, 0); } cin >> m; for (int i = 0; i < m; ++i) { string s; cin >> s; add(s, 1); } cout << (dfs(0, 0) ? "Nina" : "Emilija") << nl; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); // freopen("file.in", "r", stdin); // freopen("file.out", "w", stdout); int ttt = 1; // cin >> ttt; for (int test = 1; test <= ttt; ++test) { // cout << "Case " << test << ":" << ' '; ma1n(); } return 0; }

Compilation message (stderr)

Main.cpp: In function 'bool dfs(int, int)':
Main.cpp:56:7: warning: unused variable 'ok' [-Wunused-variable]
   56 |  bool ok = 0;
      |       ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...