Submission #934396

# Submission time Handle Problem Language Result Execution time Memory
934396 2024-02-27T09:37:47 Z bashNewbie Vlak (COCI20_vlak) C++17
70 / 70
9 ms 10700 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

#define fast_io ios::sync_with_stdio(0), cin.tie(0)
#define vi vector<int>

const int N = 2e5+7, K = 26;
int adj[2][N][K], ctr[2];

void add(string& s, int d) {
	int x = 0;
	for(char ch: s) {
		int c = ch-'a', y = adj[d][x][c];

		if(!y) adj[d][x][c] = ++ctr[d];
		x = adj[d][x][c];
	}
}

int dfs(int p, int q, int d) {
	int w = 0;
	for(int j = 0; j < K; j++) {
		int x = adj[0][p][j], y = adj[1][q][j];

		if(!x) x = N-1;
		if(!y) y = N-1;
		
		if(d == 0 && x == N-1) continue;
		if(d == 1 && y == N-1) continue;

		w |= dfs(x, y, d^1)^1;
	}
	return w;
}

int main() {
	fast_io;

	int n; string s;
	for(int k = 0; k < 2; k++) {
		cin >> n;
		for(int i = 0; i < n; i++) {
			cin >> s;
			add(s, k);
		}
	}

	int ret = dfs(0, 0, 0);
	cout << (ret? "Nina": "Emilija") << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 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 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 604 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 1 ms 552 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 0 ms 600 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 9820 KB Output is correct
2 Correct 7 ms 9308 KB Output is correct
3 Correct 7 ms 9048 KB Output is correct
4 Correct 8 ms 9904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 10072 KB Output is correct
2 Correct 6 ms 10700 KB Output is correct
3 Correct 8 ms 9820 KB Output is correct
4 Correct 6 ms 9816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 9564 KB Output is correct
2 Correct 8 ms 9308 KB Output is correct
3 Correct 9 ms 9564 KB Output is correct
4 Correct 8 ms 10328 KB Output is correct