이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
const int N = 1000000, F = 1e9;
struct Node{
int child[26];
short value, color;
Node(){
for(int i = 0; i < 26; i++) child[i] = -1;
value = color = 0;
}
};
int n, m, cur = 1;
Node trie[N];
string s[N], t[N];
bool dfs(int v, int d){
if(v == 0){
int ans = 0;
for(int i = 0; i < 26; i++) if(trie[v].child[i] != -1) ans |= dfs(trie[v].child[i], d+1);
return ans;
}
if(d & 1){
if(trie[v].color == 1){
return 1;
}else if(trie[v].color == 3){
return 1;
}else if(trie[v].value == 1){
return 1;
}else if(!(trie[v].value & 1)){
return 0;
}else{
bool ans = 1;
for(int i = 0; i < 26; i++){
if(trie[v].child[i] != -1) ans &= dfs(trie[v].child[i], d+1);
}
return ans;
}
}
if(trie[v].color == 2){
return 1;
}else if(trie[v].color == 3){
return 1;
}
else if(trie[v].value == 2){
return 1;
}else if(!(trie[v].value & 2)){
return 0;
}else{
bool ans = 0;
for(int i = 0; i < 26; i++){
if(trie[v].child[i] != -1) ans |= dfs(trie[v].child[i], d+1);
}
return ans;
}
}
int main(){
cin.tie(0); ios::sync_with_stdio(0);
cin >> n;
for(int i = 0; i < n; i++){
cin >> s[i];
int v = 0;
for(int j = 0; j < s[i].length(); j++){
if(trie[v].child[s[i][j] - 'a'] == -1){
trie[v].child[s[i][j] - 'a'] = cur++;
}
v = trie[v].child[s[i][j] - 'a'];
trie[v].value += 1;
}
trie[v].color += 1;
}
cin >> m;
for(int i = 0; i < m; i++){
cin >> t[i];
int v = 0;
for(int j = 0; j < t[i].length(); j++){
if(trie[v].child[t[i][j] - 'a'] == -1){
trie[v].child[t[i][j] - 'a'] = cur++;
}
v = trie[v].child[t[i][j] - 'a'];
trie[v].value += 2;
}
trie[v].color += 2;
}
bool ans = dfs(0, 0);
if(ans == 0) cout << "Emilija";
else cout << "Nina";
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp: In function 'int main()':
Main.cpp:67:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
67 | for(int j = 0; j < s[i].length(); j++){
| ~~^~~~~~~~~~~~~~~
Main.cpp:80:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
80 | for(int j = 0; j < t[i].length(); j++){
| ~~^~~~~~~~~~~~~~~
# | 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... |