Submission #1300683

#TimeUsernameProblemLanguageResultExecution timeMemory
1300683woodVlak (COCI20_vlak)C++20
10 / 70
22 ms41824 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 u, int d){
    if(u==-1) return false;
    bool b = false;
    for(int i = 0; i<26; i++){
        int v = A[u][i];
        int vp = B[u][i];
        if(d%2==1) swap(v,vp);
        if(v!=-1){
            b |= !dfs(vp,d+1);
        }
    }
    return b;
}
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)){
        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;
}

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:81:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   81 |         freopen((filename+".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:82:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   82 |         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...