제출 #446566

#제출 시각아이디문제언어결과실행 시간메모리
446566ArinoorVlak (COCI20_vlak)C++17
70 / 70
22 ms20428 KiB
#include <bits/stdc++.h>
using namespace std;

#define ios				ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define all(x)			x.begin(), x.end()
#define pb				push_back
#define mp				make_pai

typedef long long ll;
const int maxn = 2e5 + 10;
const int maxalpha = 26;
const int inf = 1e9 + 10;
const int mod = 1e9 + 7;

struct Trie{
	struct node{
		node * child[maxalpha];
		bool N, E;
		int h;

		node(){
			for(int i = 0; i < maxalpha; i ++)
				child[i] = nullptr;
			N = E = false;
			h = 0;
		}

		node *getChild(int c){
			if(child[c] == nullptr){
				child[c] = new node();
				child[c]->h = h + 1;
			}
			return child[c];
		}

	};
	
	node * root;

	Trie(){
		root = new node();
	}

	void add(const string *s, char player){
		node *cur = root;
		for(char c : *s){
			cur = cur->getChild(c - 'a');
			if(player == 'N')
				cur->N = true;
			else
				cur->E = true;
		}
	}

	bool dfs(node *v){
		bool fg = false;
		for(int i = 0; i < maxalpha; i ++){
			if(v->child[i] != nullptr){
				node *u = v->child[i];
				if(v->h % 2 == 0 and u->N or v->h % 2 == 1 and u->E){
					if(!dfs(u))
						fg = true;
				}
			}
		}
		return fg;
	}

} T;

int main(){
	ios;
	int n;
	cin >> n;
	for(int i = 0; i < n; i ++){
		string s;
		cin >> s;
		T.add(&s, 'N');
	}
	int m;
	cin >> m;
	for(int i = 0; i < m; i ++){
		string s;
		cin >> s;
		T.add(&s, 'E');
	}
	if(T.dfs(T.root))
		cout << "Nina\n";
	else
		cout << "Emilija\n";

}

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In member function 'bool Trie::dfs(Trie::node*)':
Main.cpp:60:22: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   60 |     if(v->h % 2 == 0 and u->N or v->h % 2 == 1 and u->E){
      |        ~~~~~~~~~~~~~~^~~~~~~~
#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...