QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#568959 | #9320. Find the Easiest Problem | yylx | WA | 0ms | 3528kb | C++14 | 1.0kb | 2024-09-16 19:32:03 | 2024-09-16 19:32:04 |
Judging History
answer
#include <iostream>
#include <unordered_map>
#include <string>
#include <algorithm>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
// Map to store problem ID and the number of teams that solved it
unordered_map<char, int> problem_counts;
for (int i = 0; i < n; ++i) {
string team_name;
char problem_id;
string result;
cin >> team_name >> problem_id >> result;
if (result == "accepted") {
problem_counts[problem_id]++;
}
}
// Find the easiest problem (most teams solved or lexicographically smallest ID)
char easiest_problem = 'A';
int max_teams = 0;
for (auto const& [problem_id, count] : problem_counts) {
if (count > max_teams) {
max_teams = count;
easiest_problem = problem_id;
} else if (count == max_teams && problem_id < easiest_problem) {
easiest_problem = problem_id;
}
}
cout << easiest_problem << endl;
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3528kb
input:
2 5 teamA A accepted teamB B rejected teamC A accepted teamB B accepted teamD C accepted 4 teamA A rejected teamB A accepted teamC B accepted teamC B accepted
output:
A B
result:
wrong answer 2nd lines differ - expected: 'A', found: 'B'