Submission #897724

# Submission time Handle Problem Language Result Execution time Memory
897724 2024-01-03T15:39:43 Z mihtriii295 Vlak (COCI20_vlak) C++17
0 / 70
7 ms 11016 KB
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define el cout << '\n'
#define TIME (1.0 * clock() / CLOCKS_PER_SEC)

/* Code by Nguyen Minh Tri (mihtriii) 12TT THPT Chuyen Ben Tre */

const ll N = 3e5 + 1;

ll n, m;

struct Node{
	Node *child[26];
	int cnt;
	bool fn;
	Node(){
		fn = 0;
		cnt = 0;
		memset(child, 0, sizeof(child));
	}
};

Node *root = new Node();
void Add(string s){
	int timer = 0;
	Node *p = root;
	for (char c : s){
		if (p -> child[c - 'a'] == 0 && c){
			p -> child[c - 'a'] = new Node();
		}
		p = p -> child[c - 'a'];
		p -> cnt = ++timer;
	}
	p -> fn = 1;
}

bool Querry(string s){
	int timer = 0;
	Node *p = root;
	for (char c : s){
		++timer;
		if (p -> child[c - 'a'] == 0){
			if (timer & 1) return 0;
			else return 1;
		}
		p = p -> child[c - 'a'];
		if (p -> fn) return 1;
	}
	return 1;
}

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    if (fopen("coci2021_r3_vlak.inp", "r")){
		freopen("coci2021_r3_vlak.inp", "r", stdin);
		freopen("coci2021_r3_vlak.out", "w", stdout);
	}
	cin >> n;
	for (int i = 1; i <= n; ++i){
		string s;
		cin >> s;
		Add(s);
	}
	bool ok = 0;
	cin >> m;
	for (int i = 1; i <= m; ++i){
		string s;
		cin >> s;
		if (Querry(s) == 0){
			ok = 1;
			break;
		}
	}
	if (ok)
		cout << "Nina";
	else
		cout << "Emilija";
	return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:60:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   60 |   freopen("coci2021_r3_vlak.inp", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:61:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |   freopen("coci2021_r3_vlak.out", "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 456 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Incorrect 1 ms 344 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 1 ms 456 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 10844 KB Output is correct
2 Incorrect 6 ms 10240 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 11016 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 10836 KB Output isn't correct
2 Halted 0 ms 0 KB -