답안 #993805

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
993805 2024-06-06T12:43:54 Z KawakiMeido Vlak (COCI20_vlak) C++17
20 / 70
1000 ms 122968 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)));
    }
//    cout << i << " " << char(f+'a') << " " << res << endl;
    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 = (DFS(0,i) || verify);
        }
    }
    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 1067 ms 122452 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 34 ms 122440 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 45 ms 122584 KB Output is correct
2 Correct 32 ms 122456 KB Output is correct
3 Correct 32 ms 122448 KB Output is correct
4 Correct 34 ms 122320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 122452 KB Output is correct
2 Correct 36 ms 122460 KB Output is correct
3 Correct 32 ms 122488 KB Output is correct
4 Correct 33 ms 122472 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1048 ms 122968 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1026 ms 122960 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1046 ms 122960 KB Time limit exceeded
2 Halted 0 ms 0 KB -