1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
| signed main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int n; std::cin >> n;
std::string a, b, c; std::cin >> a >> b >> c;
int p = a.size();
int A = 0, B = 0, C = 0; std::map<int, int> mp; for (int i = 0; i < a.size(); i++) { mp[a[i]]++; A = std::max(A, mp[a[i]]); }
mp.clear(); for (int i = 0; i < b.size(); i++) { mp[b[i]]++; B = std::max(B, mp[b[i]]); } mp.clear(); for (int i = 0; i < c.size(); i++) { mp[c[i]]++; C = std::max(C, mp[c[i]]); } if (A == p && n == 1) { A = p - 1; } else { A = std::min(p, A + n); } if (B == p && n == 1) { B = p - 1; } else { B = std::min(p, B + n); } if (C == p && n == 1) { C = p - 1; } else { C = std::min(p, C + n); }
int mx = std::max({A, B, C});
if ((A == mx && B == mx) || (C == mx && B == mx) || (A == mx && C == mx)) { std::cout << "D\n"; } else if (A == mx) { std::cout << "A\n"; } else if (B == mx) { std::cout << "B\n"; } else if (C == mx) { std::cout << "C\n"; }
return 0; }
|