QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#278174#7882. Linguistics Puzzledaredsakura#WA 1ms3588kbC++14644b2023-12-07 13:24:322023-12-07 13:24:32

Judging History

你现在查看的是最新测评结果

  • [2023-12-07 13:24:32]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3588kb
  • [2023-12-07 13:24:32]
  • 提交

answer

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;

void solve() {
    int n;
    cin >> n;
    map<string, int> cnt;
    string s;
    for (int i = 0; i < n; ++i) {
        cin >> s;
        cnt[s]++;
    }
    string ans;
    for (auto &[k, v]: cnt) {
        if (v * 2 > n) {
            ans = k;
            break;
        }
    }
    if (ans.empty())
        ans = "uh-oh";
    cout << ans << '\n';
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t = 1;
//    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3588kb

input:

2
3
a b a b b b b c cc
4
d d d d d c b a d b cd cb d a cb bc

output:

uh-oh

result:

wrong answer invalid length at case #1