# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
701361 | 2023-02-21T04:08:53 Z | Do_you_copy | Vlak (COCI20_vlak) | C++17 | 26 ms | 27752 KB |
#include <bits/stdc++.h> #define fi first #define se second #define faster ios_base::sync_with_stdio(0); cin.tie(0); #define pb push_back using namespace std; using ll = long long; using pii = pair <int, int>; const int maxN = 2e5 + 10; const int inf = 0x3f3f3f3f; //const int Mod = int n, m; string s[maxN]; string t[maxN]; struct TNode{ int a[26]; int cnt[2]; TNode(){ memset(a, 0, sizeof(a)); cnt[0] = cnt[1] = 0; } }; vector <TNode> S(1); void add1(int id, int cur, int pos){ ++S[id].cnt[0]; if (pos == signed(s[cur].length())){ return; } if (!S[id].a[s[cur][pos] - 'a']){ S[id].a[s[cur][pos] - 'a'] = S.size(); S.pb(TNode()); } add1(S[id].a[s[cur][pos] - 'a'], cur, pos + 1); } void add2(int id, int cur, int pos){ ++S[id].cnt[1]; if (pos == signed(t[cur].length())){ return; } if (!S[id].a[t[cur][pos] - 'a']){ S[id].a[t[cur][pos] - 'a'] = S.size(); S.pb(TNode()); } add2(S[id].a[t[cur][pos] - 'a'], cur, pos + 1); } bool win[maxN]; void dfs(int u, int d = 0){ if (!S[u].cnt[d & 1]){ win[u] = 0; return; } if (S[u].cnt[d & 1] && !S[u].cnt[(d & 1) ^ 1]){ win[u] = 1; return; } for (int i = 0; i < 26; ++i){ if (S[u].a[i]){ dfs(S[u].a[i], d + 1); win[u] |= win[S[u].a[i]] ^ 1; } } } void Init(){ cin >> n; for (int i = 1; i <= n; ++i){ cin >> s[i]; add1(0, i, 0); } cin >> m; for (int i = 1; i <= m; ++i){ cin >> t[i]; add2(0, i, 0); } dfs(0); if (win[0]) cout << "Nina"; else cout << "Emilija"; } #define taskname "test" signed main(){ faster if (fopen(taskname ".inp", "r")){ freopen(taskname ".inp", "r", stdin); freopen(taskname ".out", "w", stdout); } int tt = 1; //cin >> tt; while (tt--){ Init(); } if (fopen("timeout.txt", "r")){ ofstream timeout("timeout.txt"); cerr << "Time elapsed: " << signed(double(clock()) / CLOCKS_PER_SEC * 1000) << "ms\n"; timeout << signed(double(clock()) / CLOCKS_PER_SEC * 1000); timeout.close(); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 13144 KB | Output is correct |
2 | Correct | 7 ms | 13140 KB | Output is correct |
3 | Correct | 8 ms | 13140 KB | Output is correct |
4 | Correct | 7 ms | 13108 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 13140 KB | Output is correct |
2 | Correct | 7 ms | 13112 KB | Output is correct |
3 | Correct | 7 ms | 13128 KB | Output is correct |
4 | Correct | 8 ms | 13140 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 12984 KB | Output is correct |
2 | Correct | 7 ms | 13140 KB | Output is correct |
3 | Correct | 7 ms | 13012 KB | Output is correct |
4 | Correct | 7 ms | 13108 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 12980 KB | Output is correct |
2 | Correct | 6 ms | 13196 KB | Output is correct |
3 | Correct | 7 ms | 13140 KB | Output is correct |
4 | Correct | 6 ms | 13012 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 24 ms | 27668 KB | Output is correct |
2 | Correct | 24 ms | 27700 KB | Output is correct |
3 | Correct | 22 ms | 27700 KB | Output is correct |
4 | Correct | 23 ms | 27752 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 27572 KB | Output is correct |
2 | Correct | 22 ms | 27584 KB | Output is correct |
3 | Correct | 21 ms | 27608 KB | Output is correct |
4 | Correct | 26 ms | 27580 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 26 ms | 27588 KB | Output is correct |
2 | Correct | 22 ms | 27580 KB | Output is correct |
3 | Correct | 21 ms | 27700 KB | Output is correct |
4 | Correct | 22 ms | 27588 KB | Output is correct |