답안 #993797

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
993797 2024-06-06T12:37:24 Z KawakiMeido Vlak (COCI20_vlak) C++17
20 / 70
1000 ms 123224 KB
/*Author: KawakiMeido*/
#include <bits/stdc++.h>
#define pb push_back
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define fi first
#define se second

using namespace std;

/*Constants*/
const int N = 2e5+10;
const int INF = 1e9+7;
const long long LLINF = 1e18+3;

/*TestCases*/
int test=1;
void solve();
void TestCases(bool v){
    if (v) cin >> test;
    while(test--) solve();
}

/*Global Variables*/
int n,m;
bool exist[26];
vector<int> a[N][26];

bool DFS(int i, int f){
    bool res = true;
    for (auto idx:a[i][f]){
        res = (res && (!DFS(i+1,idx)));
    }
    return res;
}

/*Solution*/
void solve(){
    string s;
    cin >> n;
    for (int i=1; i<=n; i++){
        cin >> s;
        exist[s[0]-'a'] = true;
        for (int j=1; j<(int)s.size(); j++){
            if (j%2==0){
                a[j-1][s[j-1]-'a'].push_back(s[j]-'a');
            }
        }
    }
    cin >> m;
    for (int i=1; i<=m; i++){
        cin >> s;
        for (int j=0; j<(int)s.size(); j++){
            if (j%2){
                a[j-1][s[j-1]-'a'].push_back(s[j]-'a');
            }
        }
    }
    bool verify = 0;
    for (int i=0; i<26; i++){
        if (exist[i]){
            verify = (verify || DFS(0,i));
        }
    }
    if (verify) cout << "Nina" << endl;
    else cout << "Emilija" << endl;
}


/*Driver Code*/
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    TestCases(0);

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1018 ms 122456 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 29 ms 122448 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 122460 KB Output is correct
2 Correct 21 ms 122456 KB Output is correct
3 Correct 21 ms 122460 KB Output is correct
4 Correct 21 ms 122456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 122396 KB Output is correct
2 Correct 22 ms 122460 KB Output is correct
3 Correct 22 ms 122460 KB Output is correct
4 Correct 23 ms 122712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1042 ms 123184 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1093 ms 123216 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1032 ms 123224 KB Time limit exceeded
2 Halted 0 ms 0 KB -