QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#573040 | #9320. Find the Easiest Problem | feifange | RE | 0ms | 0kb | C++14 | 2.0kb | 2024-09-18 17:09:12 | 2024-09-18 17:09:13 |
answer
#include <iostream>
#include <cstring>
using namespace std;
int main() {
int t, n;
cin >> t; // 读取测试用例数量
while (t--) {
cin >> n; // 读取每个测试用例的提交数量
// 初始化问题统计数组,假设最多26个问题(A-Z)
int solvedCount[26] = {0};
char teamNames[100001][11]; // 存储所有团队名称,预留足够空间
bool teamSeen[100001] = {false}; // 标记团队是否已解决某问题
// 读取提交记录
for (int i = 0; i < n; i++) {
char team[11], problem;
string result;
cin >> team >> problem >> result;
// 将团队名称转换为整数索引(简单哈希,基于题目保证团队名不同)
int teamIndex = 0;
for (int j = 0; team[j] != '\0'; j++) {
teamIndex = teamIndex * 26 + (team[j] - 'A');
}
// 如果这是该团队第一次解决此问题,增加计数器
if (!teamSeen[teamIndex] && result == "accepted") {
teamSeen[teamIndex] = true;
solvedCount[problem - 'A']++;
}
// 存储团队名称,仅为了演示,实际代码中未使用
strcpy(teamNames[i], team);
}
// 寻找最易问题
char easiestProblem = 'Z' + 1; // 初始化为大于'Z'的字符
int maxTeams = 0;
for (int i = 0; i < 26; i++) {
if (solvedCount[i] > maxTeams || (solvedCount[i] == maxTeams && easiestProblem > 'A' + i)) {
maxTeams = solvedCount[i];
easiestProblem = 'A' + i;
}
}
// 输出结果
cout << easiestProblem << endl;
}
return 0;
}
詳細信息
Test #1:
score: 0
Runtime Error
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