Submission #1014126

# Submission time Handle Problem Language Result Execution time Memory
1014126 2024-07-04T11:45:51 Z vjudge1 Vlak (COCI20_vlak) C++17
70 / 70
9 ms 12124 KB
#include <bits/stdc++.h>
#define ll long long
#define pii pair <int, int>
using namespace std;
const int siz = 28;
const int N = 2e6 + 10;
const int M = 2e5 + 10;
struct node {
	int ch[siz];
	int vis[2], sum[2];
} trie[N];
char c[M];
bool fg[N];
int rt = 0, ncnt = 0;
inline void insert(char *s, int who) {
	int p = rt;
	for (int i = 0; s[i]; ++i) {
		int j = s[i] - 'a';
		if (!trie[p].ch[j]) trie[p].ch[j] = ++ncnt;
		p = trie[p].ch[j];
		trie[p].sum[who] ++;
	}
	trie[p].vis[who] ++;
}
inline void solve(int p, int who) {
	for (int i = 0; i < siz; ++i) {
		if (trie[p].ch[i]) {
			solve(trie[p].ch[i], who ^ 1);
			if (trie[trie[p].ch[i]].sum[who] > 0) {
				if (!fg[trie[p].ch[i]]) {
					fg[p] = true;
					return ;
				}
			}
		}
	}
	fg[p] = false;
}
int main() {
	int n, m; scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%s", c);
		insert(c, 0);
	}
	scanf("%d", &m);
	for (int i = 1; i <= m; ++i) {
		scanf("%s", c);
		insert(c, 1);
	}
	solve(0, 0);
	if (fg[0]) printf("Nina");
	else printf("Emilija");
	//11 11 11 11 11 11 Yeah
	return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:40:17: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |  int n, m; scanf("%d", &n);
      |            ~~~~~^~~~~~~~~~
Main.cpp:42:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |   scanf("%s", c);
      |   ~~~~~^~~~~~~~~
Main.cpp:45:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   45 |  scanf("%d", &m);
      |  ~~~~~^~~~~~~~~~
Main.cpp:47:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |   scanf("%s", c);
      |   ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 444 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 448 KB Output is correct
4 Correct 0 ms 448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 11356 KB Output is correct
2 Correct 6 ms 10588 KB Output is correct
3 Correct 5 ms 10076 KB Output is correct
4 Correct 9 ms 11100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 11484 KB Output is correct
2 Correct 5 ms 12124 KB Output is correct
3 Correct 4 ms 10984 KB Output is correct
4 Correct 5 ms 11356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 10844 KB Output is correct
2 Correct 5 ms 10568 KB Output is correct
3 Correct 5 ms 10844 KB Output is correct
4 Correct 6 ms 11612 KB Output is correct