답안 #564146

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
564146 2022-05-18T15:37:22 Z Soul234 Vlak (COCI20_vlak) C++14
70 / 70
10 ms 10068 KB
#include<bits/stdc++.h>
using namespace std;

void DBG() { cerr << "]\n"; }
template<class H, class... T> void DBG(H h, T... t) {
    cerr << h; if(sizeof...(t)) cerr << ", ";
    DBG(t...);
}
#ifdef LOCAL
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define dbg(...) 0
#endif // LOCAL

#define FOR(i,a,b) for(int i = (a) ; i<(b) ; i++)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for(int i = (b)-1 ; i>=(a) ; i--)
#define R0F(i,a) ROF(i,0,a)
#define each(e,a) for(auto &e : (a))
#define sz(v) (int)(v).size()
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb push_back
#define tcT template<class T
#define nl "\n"

using ll = long long;
using vi = vector<int>;
using pi = pair<int,int>;
using str = string;
tcT> using V = vector<T>;
tcT> using pqg = priority_queue<T,vector<T>,greater<T>>;

void setIO(string NAME = "") {
    cin.tie(0)->sync_with_stdio(0);
    if(sz(NAME)) {
        freopen((NAME + ".inp").c_str(),"r",stdin);
        freopen((NAME + ".out").c_str(),"w",stdout);
    }
}

constexpr bool onbit(int x, int i) { return x>>i&1; }
const int MX = 2e5+5;
int nu[MX][26], val[MX], nnod;

void add(str s, int x) {
    int cur = 0;
    F0R(i,sz(s)) {
        int t = s[i] - 'a';
        if(!nu[cur][t]) nu[cur][t] = ++nnod;
        val[cur = nu[cur][t]] |= x;
    }
}

bool dfs(int u, int x) {
    F0R(c,26) {
        if(!nu[u][c]) continue;
        int nxt = nu[u][c];
        if(!onbit(val[nxt], x)) continue;
        if(!onbit(val[nxt], x^1)) return 1;
        else if(!dfs(nxt, x^1)) return 1;
    }
    return 0;
}

int N, M;

void solve() {
    cin>>N;
    F0R(i,N) {
        str s; cin>>s;
        add(s, 1);
    }
    cin>>M;
    F0R(i,M) {
        str s; cin>>s;
        add(s, 2);
    }
    cout << (dfs(0,0)?"Nina":"Emilija") << nl;
}

int main() {
    setIO();

    int t=1;
    //cin>>t;
    while(t-->0) {
        solve();
    }

    return 0;
}

Compilation message

Main.cpp: In function 'void setIO(std::string)':
Main.cpp:37:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |         freopen((NAME + ".inp").c_str(),"r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:38:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |         freopen((NAME + ".out").c_str(),"w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 9428 KB Output is correct
2 Correct 9 ms 8916 KB Output is correct
3 Correct 8 ms 8404 KB Output is correct
4 Correct 10 ms 9304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 9608 KB Output is correct
2 Correct 8 ms 10068 KB Output is correct
3 Correct 8 ms 9300 KB Output is correct
4 Correct 8 ms 9428 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 9144 KB Output is correct
2 Correct 8 ms 8920 KB Output is correct
3 Correct 9 ms 9172 KB Output is correct
4 Correct 9 ms 9712 KB Output is correct