Submission #862984

# Submission time Handle Problem Language Result Execution time Memory
862984 2023-10-19T12:28:31 Z duckindog Vlak (COCI20_vlak) C++14
0 / 70
17 ms 63436 KB
// from duckindog wth depression
#include<bits/stdc++.h>

using namespace std;

const int N = 4 * (2e5 + 10);
string a[N], b[N];
int nwt[N][27];
int st[N];

int it, bit;
void add(string x, int y) {
  int g = 0;
  for (auto ch : x) {
    st[g] |= y;
    int w = ch - 'a' + 1;
    if (!nwt[g][w]) nwt[g][w] = ++it;
    g = nwt[g][w];
  } st[g] |= y;
  return;
}

void dfs(int g = 0) {
  for (int i = 0; i <= 26; ++i) {
    if (!nwt[g][i]) continue;
    char ni = !i ? '0' : char(i + 'a' - 1);
    cout << g << " " << nwt[g][i] << " " << ni << "\n";
    dfs(nwt[g][i]);
  }
  return;
}

bool answer;
void check(int g = 0, int y = 0) {
  bool w = 0;
  for (int i = 1; i <= 26; ++i) {
    int ny = y + 1;
    int need = ny % 2;
    bool trapdoor = 0;
    int v = nwt[g][i];
    if (need && st[v] % 2 == 1) trapdoor = 1;
    if (!need && st[v] >= 2) trapdoor = 1;
    if (!v || !trapdoor) continue;
    w = 1;
    check(v, ny);
  }
  if (!w && y % 2 == 1) {
    cout << "Nina";
    exit(0);
  }
  return;
}

int32_t main() {
  cin.tie(0)->sync_with_stdio(0);

  if (fopen("duck.inp", "r")) {
    freopen("duck.inp", "r", stdin);
    freopen("duck.out", "w", stdout);
  }
  int n; cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i], bit = max(bit, int(a[i].size()));
  int m; cin >> m;
  for (int i = 1; i <= m; ++i) cin >> b[i], bit = max(bit, int(b[i].size()));

  for (int i = 1; i <= n; ++i) add(a[i], 1);
  for (int i = 1; i <= m; ++i) add(b[i], 2);
  check();
  cout << "Emilija";
}

Compilation message

Main.cpp: In function 'int32_t main()':
Main.cpp:58:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   58 |     freopen("duck.inp", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:59:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   59 |     freopen("duck.out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 51804 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 51800 KB Output is correct
2 Correct 11 ms 51876 KB Output is correct
3 Correct 11 ms 51804 KB Output is correct
4 Incorrect 12 ms 51800 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 51800 KB Output is correct
2 Correct 10 ms 51804 KB Output is correct
3 Incorrect 12 ms 52224 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 51800 KB Output is correct
2 Correct 10 ms 51800 KB Output is correct
3 Correct 10 ms 51804 KB Output is correct
4 Incorrect 10 ms 51804 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 63324 KB Output is correct
2 Incorrect 17 ms 62812 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 63436 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 63064 KB Output isn't correct
2 Halted 0 ms 0 KB -