답안 #487515

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
487515 2021-11-15T21:32:31 Z Nimbostratus Vlak (COCI20_vlak) C++17
10 / 70
24 ms 25400 KB
#include "bits/stdc++.h"
using namespace std;
#define endl '\n'
using lint = long long;
using pii = pair<int,int>;
constexpr int maxn = 2e5+5;
constexpr int inf = 2e9;
constexpr int mod = 1e9+7;

struct Node {
	vector<int> nxt = vector<int>(26, 0);
	bool end[2] = {false, false};
};

vector<Node> t = vector<Node>(1);
	
void addWord(string& s, int p, int nd = 0, int idx = 0) {
	if(idx == s.size() - 1) {
		t[nd].end[p] = true;
		return;
	}
	if(!t[nd].nxt[s[idx] - 'a']) {
		t.push_back(Node());
		t[nd].nxt[s[idx] - 'a'] = t.size() - 1;
	}
	addWord(s, p, t[nd].nxt[s[idx] - 'a'], idx + 1);
}

bool solve(int u = 0, int d = 0) {
	if(t[u].end[d & 1])
		return true;
	bool ret = false;
	for(int v : t[u].nxt) {
		if(!v)
			continue;
		int res = solve(v, d + 1);
		ret |= !res;
	}
	return ret;
}

int n, m;
string a[maxn], b[maxn];

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		addWord(a[i], 1);
	}
	cin >> m;
	for(int i = 0; i < m; i++) {
		cin >> b[i];
		addWord(b[i], 0);
	}
	cout << (solve() ? "Nina" : "Emilija") << endl;
}

Compilation message

Main.cpp: In function 'void addWord(std::string&, int, int, int)':
Main.cpp:18:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |  if(idx == s.size() - 1) {
      |     ~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 13004 KB Output is correct
2 Correct 7 ms 13004 KB Output is correct
3 Incorrect 6 ms 13004 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 13004 KB Output is correct
2 Correct 6 ms 12968 KB Output is correct
3 Incorrect 6 ms 12880 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 12876 KB Output is correct
2 Incorrect 6 ms 12856 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 12876 KB Output is correct
2 Correct 6 ms 12880 KB Output is correct
3 Correct 6 ms 12880 KB Output is correct
4 Correct 6 ms 12908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 24380 KB Output is correct
2 Incorrect 23 ms 24640 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 24880 KB Output is correct
2 Incorrect 24 ms 25400 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 24380 KB Output is correct
2 Incorrect 22 ms 24376 KB Output isn't correct
3 Halted 0 ms 0 KB -