제출 #1300687

#제출 시각아이디문제언어결과실행 시간메모리
1300687woodVlak (COCI20_vlak)C++20
70 / 70
21 ms41936 KiB
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
#define vint vector<int>
#define vpint vector<pint>
#define vll vector<ll>
#define vpll vector<pll>
#define fast_cin()                                                             \
    ios_base::sync_with_stdio(false);                                          \
    cin.tie(NULL);                                                             \
    cout.tie(NULL)
#define MOD %= 1000000007
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <class T>
using Tree =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 2e5+2;
int A[N][26];
int B[N][26];
bool dfs(int a, int b, int d){
    int ua = a, ub = b;
    if(d%2==1) swap(ua,ub);
    if(ua==-1) return false;
    if(ub==-1) return true;
    bool res = false;
    for(int i = 0; i<26; i++){
        int v = A[a][i];
        int vp = B[b][i];
        if(d%2==0&&v!=-1){
            res |= !dfs(v,vp,d+1);
        }
        if(d%2==1&&vp!=-1){
            res |= !dfs(v,vp,d+1);
        }
    }
    return res;
}
void solve() {
    int n; cin>>n;
    string s[n];
    for(int i = 0; i<n; i++) cin>>s[i];
    int m; cin>>m;
    string b[m];
    for(int i = 0; i<m; i++) cin>>b[i];
    memset(A,-1,sizeof A);
    memset(B,-1,sizeof B);
    int nodecnt = 1;
    for(auto x : s){
        int node = 0;
        for(auto c : x){
            if(A[node][c-'a']==-1) A[node][c-'a'] = nodecnt++;
            node = A[node][c-'a'];
        }
    }
    nodecnt = 1;
    for(auto x : b){
        int node = 0;
        for(auto c : x){
            if(B[node][c-'a']==-1) B[node][c-'a'] = nodecnt++;
            node = B[node][c-'a'];
        }
    }
    if(dfs(0,0,0)){
        cout<<"Nina\n";
    }
    else{
        cout<<"Emilija\n";
    }
}
int main() {
    fast_cin();
#ifdef MYPC
    freopen("input.in", "r", stdin);
#else
    string filename="";
    if(!filename.empty()) {
        freopen((filename+".in").c_str(), "r", stdin);
        freopen((filename+".out").c_str(), "w", stdout);
    }
#endif
    int t;
    t = 1;
    while (t--) {
        solve();
    }
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:86:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   86 |         freopen((filename+".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:87:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   87 |         freopen((filename+".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...