Submission #961965

# Submission time Handle Problem Language Result Execution time Memory
961965 2024-04-12T22:44:26 Z rnazymxan Vlak (COCI20_vlak) C++17
0 / 70
1000 ms 600 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();
		freopen("input.in", "r", stdin);
        freopen("input.out", "w", stdout);
		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:10: 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:10: 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);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:65:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   65 |   freopen("input.in", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:66:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   66 |         freopen("input.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 1002 ms 600 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1029 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1061 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1018 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1008 ms 600 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 1032 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -