Submission #961964

# Submission time Handle Problem Language Result Execution time Memory
961964 2024-04-12T22:43:20 Z rnazymxan Vlak (COCI20_vlak) C++17
0 / 70
1000 ms 348 KB
#include<iostream>
#include<unordered_map>
#include<vector>
using namespace std;

#define ll long long

void init_code(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}

const int N = 1e5 + 11;

struct Node {
	Node* node[26];

	Node(){
		for(int i = 0; i < 26; i++){
			node[i] = NULL;
		}
	}

};


void add(Node* root, string s){
	int ptr = 0;
	int n = s.size();
	while(ptr < n){
		if(root->node[s[ptr] - 'a'] != NULL){
			root = root->node[s[ptr] - 'a'];
		}else{
			root->node[s[ptr] - 'a'] = new Node();
			root = root->node[s[ptr] - 'a'];
		}
		ptr++;
	}
}

bool win(Node* trie1, Node* trie2){
	for(int i = 0; i < 26; i++){
		if(trie1->node[i] != NULL && trie2->node[i] == NULL){
			return true;
		}
	}

	bool hehe = false;

	for(int i = 0; i < 26; i++){
		if(trie1->node[i] != NULL){
			hehe |= !win(trie2 -> node[i], trie1 -> node[i]);
		}
	}


	return hehe;
}

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);		
	init_code();
	int n;
	string s;
	cin >> n;
	Node *trie1 = new Node();
	Node *trie2 = new Node();
	while(n--){
		cin >> s;
		add(trie1, s);
	}

	cin >> n;

	while(n--){
		cin >> s;
		add(trie2, s);
	}

	if(win(trie1, trie2)){
		cout << "Nina";
	}else{
		cout << "Emilija";
	}


}

Compilation message

Main.cpp: In function 'void init_code()':
Main.cpp:10:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |  freopen("input.txt", "r", stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:11:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |  freopen("output.txt", "w", stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 1063 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1078 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1058 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1041 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1032 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1041 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1035 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -