#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f(i, a, b) for (int i = (a); i <= (b); i++)
#define fo(i, a, b) for (int i = (a); i >= (b); i--)
#define minimize(a, b) (a) = ((a) < (b) ? (a) : (b))
#define maximize(a, b) (a) = ((a) > (b) ? (a) : (b))
#define fi first
#define se second
#define ll long long
#define pii pair <int, int>
#define pb push_back
#define pi acos(-1)
#define sz(a) (int)a.size()
#define getbit(a, b) (((a) >> (b)) & 1)
#define INOUT "main"
#define INFT 0x3f3f3f3f
#define debug1(a, st, en) { cout << #a << " = ["; int kt = false; f(i, st, en) {if (kt) cout << ", "; kt = true; cout << a[i];} cout << "]\n"; }
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << '\n';}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
cout << *it << " = [" << a << "]" << ' ';
err(++it, args...);
}
void ctime()
{
cerr << "\n" << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
}
void file()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
if (fopen(INOUT".inp", "r"))
{
freopen(INOUT".inp", "r", stdin);
freopen(INOUT".out", "w", stdout);
}
}
const int MOD = 998244353;
int n;
struct Node
{
Node* child[26];
bool exist[2];
Node()
{
f(i, 0, 25)
{
child[i] = NULL;
exist[0] = exist[1] = 0;
}
}
};
Node root;
void ADD(string s, int type)
{
Node* cur = &root;
for (auto c : s)
{
int x = c - 'a';
if (cur->child[x] == NULL)
cur->child[x] = new Node();
cur = cur->child[x];
cur->exist[type] = true;
}
}
bool FIND(Node* cur, int turn)
{
f(c, 0, 25)
{
if (cur->child[c] == NULL)
continue;
if (!cur->child[c]->exist[turn ^ 1])
return true;
if (FIND(cur->child[c], turn ^ 1) == 0)
return true;
}
return false;
}
signed main()
{
file();
cin >> n;
f(i, 1, n)
{
string s;
cin >> s;
ADD(s, 0);
}
cin >> n;
f(i, 1, n)
{
string s;
cin >> s;
ADD(s, 1);
}
if (FIND(&root, 0)) cout << "Nina";
else cout << "Emilija";
ctime();
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp: In function 'void file()':
Main.cpp:41:20: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
41 | freopen(INOUT".inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:42:20: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
42 | freopen(INOUT".out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |