# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1087762 | 2024-09-13T08:04:10 Z | shidou26 | Vlak (COCI20_vlak) | C++14 | 20 ms | 35416 KB |
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define all(v) v.begin(), v.end() typedef long long ll; typedef pair<int, int> ii; typedef pair<ll, int> li; const int N = 2e5 + 3; struct node { int num_child; node* children[26]; node () { num_child = 0; for(int i = 0; i < 26; i++) children[i] = nullptr; } }; int n, m; string a[N], b[N]; node *one = new node(); node *two = new node(); void prepare() { } void input() { cin >> n; for(int i = 1; i <= n; i++) { cin >> a[i]; } cin >> m; for(int i = 1; i <= m; i++) { cin >> b[i]; } } void insert(int type, string s) { node *current = (type == 0 ? one : two); for(int i = 0; i < (int)s.size(); i++) { int ch = (s[i] - 'a'); if(current -> children[ch] == nullptr) { current -> children[ch] = new node(); current -> num_child++; } current = current -> children[ch]; } } void process() { for(int i = 1; i <= n; i++) insert(0, a[i]); for(int i = 1; i <= m; i++) insert(1, b[i]); node *current_one = one; node *current_two = two; for(int turn = 1; true; turn++) { if(turn & 1) { int diff = -1e9, ch = 0; for(int i = 0; i < 26; i++) { if(current_one -> children[i] != nullptr && current_two -> children[i] == nullptr) { cout << "Nina" << endl; return; } if(current_one -> children[i] == nullptr) continue; int gap = current_one -> children[i] -> num_child - current_two -> children[i] -> num_child; if(diff < gap) { diff = gap; ch = i; } } current_one = current_one -> children[ch]; }else { int diff = -1e9, ch = 0; for(int i = 0; i < 26; i++) { if(current_two -> children[i] != nullptr && current_one -> children[i] == nullptr) { cout << "Emilija" << endl; return; } if(current_two -> children[i] == nullptr) continue; int gap = current_two -> children[i] -> num_child - current_one -> children[i] -> num_child; if(diff < gap) { diff = gap; ch = i; } } current_two = current_two -> children[ch]; } } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); #define task "kurumi" if(fopen(task".INP", "r")) { freopen(task".INP", "r", stdin); freopen(task".OUT", "w", stdout); } prepare(); int testcase = 1; // cin >> testcase; for(int i = 1; i <= testcase; i++) { input(); process(); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 13144 KB | Output is correct |
2 | Correct | 5 ms | 13148 KB | Output is correct |
3 | Incorrect | 5 ms | 13128 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 13148 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 13016 KB | Output is correct |
2 | Incorrect | 5 ms | 13148 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 13148 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 18 ms | 34132 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 34396 KB | Output is correct |
2 | Correct | 20 ms | 35416 KB | Output is correct |
3 | Correct | 15 ms | 33560 KB | Output is correct |
4 | Incorrect | 16 ms | 33872 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 33372 KB | Output is correct |
2 | Correct | 19 ms | 32860 KB | Output is correct |
3 | Incorrect | 17 ms | 33116 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |