Submission #428002

# Submission time Handle Problem Language Result Execution time Memory
428002 2021-06-15T07:01:52 Z Atlant Vlak (COCI20_vlak) C++14
70 / 70
40 ms 13476 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define endl '\n'
#define SZ(x) (int)((x).size())
#define dem(x) __builtin_popcount(x)
#define fi first
#define se second
//#define int long long
typedef pair<int,int> ii;
typedef long long ll;
const ll mod = 1e9 + 7; //998244353
const ll base = 9973;
vector<int> a[400005];
char c[400005];
string s;
int d[400005], n, f[400005], cnt;
/// 1: blue    2: red
void add(int id,string s,int it,int val)
{
    if(it == SZ(s)){
        if(f[id] == 1 && d[id] == 0 && val == 2)f[id] = 2;
        if(f[id] == 2 && d[id] == 1 && val == 1)f[id] = 1;
        if(f[id] == 0)f[id] = val;
        return;
    }
    bool ck = 1;
    for(int i : a[id])if(c[i] == s[it]){
        d[i] = d[id] ^ 1;
        ck = 0;
        add(i, s, it + 1, val);
        break;
    }
    if(ck){
        cnt++;
        a[id].pb(cnt);
        c[cnt] = s[it];
        d[cnt] = d[id] ^ 1;
        add(cnt, s, it + 1, val);
    }
}
void DFS(int id)
{
    if(SZ(a[id]) == 0)return;
    for(int i : a[id]){
        DFS(i);
        if(f[id] == 0)f[id] = f[i];
        if(d[id] == 0 && f[i] == 1)f[id] = 1;
        if(d[id] == 1 && f[i] == 2)f[id] = 2;
    }
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
//    freopen("c.inp","r",stdin);
    cin >> n;
    while(n--){
        cin >> s;
        add(0, s, 0, 1);
    }
    cin >> n;
    while(n--){
        cin >> s;
        add(0, s, 0, 2);
    }
    for(int i = 0;i <= cnt;++i)if(SZ(a[i]))f[i] = 0;
    DFS(0);
    cout << (f[0] == 1 ? "Nina" : "Emilija");
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 9804 KB Output is correct
2 Correct 6 ms 9676 KB Output is correct
3 Correct 7 ms 9724 KB Output is correct
4 Correct 6 ms 9760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 9720 KB Output is correct
2 Correct 7 ms 9676 KB Output is correct
3 Correct 8 ms 9676 KB Output is correct
4 Correct 7 ms 9676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 9676 KB Output is correct
2 Correct 6 ms 9676 KB Output is correct
3 Correct 6 ms 9676 KB Output is correct
4 Correct 6 ms 9724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 9804 KB Output is correct
2 Correct 6 ms 9804 KB Output is correct
3 Correct 6 ms 9676 KB Output is correct
4 Correct 8 ms 9724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 12956 KB Output is correct
2 Correct 30 ms 12760 KB Output is correct
3 Correct 40 ms 12648 KB Output is correct
4 Correct 34 ms 12936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 13312 KB Output is correct
2 Correct 29 ms 13476 KB Output is correct
3 Correct 28 ms 13132 KB Output is correct
4 Correct 28 ms 13228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 13016 KB Output is correct
2 Correct 30 ms 12876 KB Output is correct
3 Correct 30 ms 12968 KB Output is correct
4 Correct 33 ms 13260 KB Output is correct