이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
# include <bits/stdc++.h>
# define pb push_back
# define ff first
# define ss second
# define nl "\n"
# define sz(x) ((int)(x).size())
# define deb(x) cerr << #x << " = " << x << endl;
# define pll pair <ll, ll>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll maxn = 2e5 + 25;
const ll inf = 2e9 + 0;
const ll mod = 1e9 + 123;
const ll dx[] = {-1, 1, 0, 0};
const ll dy[] = {0, 0, -1, 1};
using namespace std;
struct vertex
{
int nxt[26];
int mask;
vertex ()
{
memset(nxt, -1, sizeof nxt);
mask = 0;
}
};
int n, m;
vertex t[maxn];
int nv = 1;
void add (string s, int bit)
{
int v = 0;
for (int i = 0; i < sz(s); ++i)
{
t[v].mask |= (1 << bit);
int c = s[i] - 'a';
if (t[v].nxt[c] == -1)
{
t[v].nxt[c] = nv++;
}
v = t[v].nxt[c];
}
t[v].mask |= (1 << bit);
}
bool dfs (int v, int turn)
{
bool ok = 0;
for (int c = 0; c < 26; ++c)
{
ll to = t[v].nxt[c];
if (to == -1) continue;
if (t[to].mask & (1LL << turn) && !dfs(to, turn ^ 1))
{
return 1;
}
}
return 0;
}
void ma1n (/* SABR */)
{
cin >> n;
for (int i = 0; i < n; ++i)
{
string s;
cin >> s;
add(s, 0);
}
cin >> m;
for (int i = 0; i < m; ++i)
{
string s;
cin >> s;
add(s, 1);
}
cout << (dfs(0, 0) ? "Nina" : "Emilija") << nl;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
// freopen("file.in", "r", stdin);
// freopen("file.out", "w", stdout);
int ttt = 1;
// cin >> ttt;
for (int test = 1; test <= ttt; ++test)
{
// cout << "Case " << test << ":" << ' ';
ma1n();
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp: In function 'bool dfs(int, int)':
Main.cpp:56:7: warning: unused variable 'ok' [-Wunused-variable]
56 | bool ok = 0;
| ^~
# | 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... |