QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#570351 | #9320. Find the Easiest Problem | LKB | RE | 0ms | 0kb | C++23 | 1.6kb | 2024-09-17 15:25:47 | 2024-09-17 15:25:48 |
answer
#include<bits/stdc++.h>
using namespace std;
struct node{
string a;
char ti;
string result;
};
bool cmp(node x, node y){
if(x.a.size() == y.a.size()){
return x.a[x.a.size()-1] > y.a[y.a.size()-1];
} else return x.a.size() > y.a.size();
}
int main(){
int t;
cin >> t;
while(t--){
node c[1000000];
int n, i;
int *SUM = new int[26]();
int *sum = new int[26]();
cin >> n;
for(i = 0; i < n; i++){
string str, strr;
char qq;
int p = 1;
cin >> str >> qq >> strr;
if(strr == "rejected") continue;
else {
c[i].a = str;
c[i].ti = qq;
c[i].result = strr;
}
}
sort(c, c+n, cmp);
for(i = 0; i < sizeof(c); i++){
if(i == 0){
// if(c[i].result == "rejected")continue;
for(int j = 0; j < 26; j++){
sum[j] = 0;
}
if(sum[c[i].ti - 'A'] == 0){
SUM[c[i].ti - 'A']++;
sum[c[i].ti - 'A'] = 1;
}
}else {
if(c[i].a == c[i-1].a){
// if(c[i].result == "rejected")continue;
if(sum[c[i].ti - 'A'] == 0){
SUM[c[i].ti - 'A']++;
sum[c[i].ti - 'A'] = 1;
} else continue;
}
if(c[i].a != c[i-1].a){
for(int j = 0; j < 26; j++){
sum[j] = 0;
}
// if(c[i].result == "rejected")continue;
if(sum[c[i].ti - 'A'] == 0){
SUM[c[i].ti - 'A']++;
sum[c[i].ti - 'A'] = 1;
}
}
}
}
int k = 0, l = 0;
for(i = 0; i < 26; i++){
if(SUM[i] > k) {k = SUM[i]; l = i;}
// cout << SUM[i] << endl;
}
char s = l + 'A';
cout << s;
if(t != 0) cout << 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