<aside> ⚠️ 假設隊伍答對A題後,後面再出現對A題的正確或錯誤提交皆不影響時間 假設隊伍提交答錯B題,若最終沒有答對B題,則答錯B題的懲罰時間不會計算 只要隊伍提交過選項,即使不影響時間 (R, U, E),仍然算有出場 (即要print出來)
</aside>
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
pair<bool, int> m = {false, 0}; //初始化用
struct str{
int pro = 0; //解題數
int t = 0; //總耗時
int con = 999; //參賽隊伍數字(1~100)
pair<bool, int> p[10] = {m}; //該隊的解題狀況 (是否解題, 錯誤懲罰時間)
bool f = false;//該隊伍是否參加
};
bool cmp(str s1, str s2){ //struct排序
if(s1.f + s2.f == 1)
return s1.con < s2.con;
if(s1.pro == s2.pro){
if(s1.t == s2.t)
return s1.con < s2.con;
else
return s1.t < s2.t;
}
else
return s1.pro > s2.pro;
}
int main(){
fstream file;
file.open("output.txt");
fclose(fopen("output.txt", "w"));
string input, temp;
int t;
cin >> t;
cin.ignore();
getline(cin, temp); //多讀取一個換行 題目輸入要求
while(t--){
vector<str> v(101);
while(getline(cin, input)){
if(input == "")break;
int contest, problem, time = 0; //提交的隊伍, 提交的問題, 提交時間
char L; //提交選項
int c = 1, index = 0;
while(c < 5){ //提取輸入資料
switch(c){
case 1 : //提取參賽隊伍數字
if(input[1] == ' '){
contest = input[0] - '0';
index = 2;
}
else if(input[2] == ' '){
contest = (input[0]-'0')*10 + input[1] - '0';
index = 3;
}
else{
contest = 100;
index = 4;
}
c++;
break;
case 2 : //提取題目數字
problem = input[index] - '0';
c++;
index += 2;
break;
case 3 : //提取時間數字
while(input[index] != ' '){
time *= 10;
time += (input[index] - '0');
index++;
}
index++;
c++;
break;
case 4 : //提取提交選項
L = input[index];
c++;
break;
}
}
v[contest].con = contest;
v[contest].f = true;
if(L == 'C'){
if(v[contest].p[problem-1].first == false){ //若該題尚未解過
v[contest].pro++; //解題數+1
v[contest].t += time; //增加耗時
v[contest].t += v[contest].p[problem-1].second; //增加錯誤懲罰時間
v[contest].p[problem-1].first = true; //改為已解過
}
}
else if(L == 'I'){
if(v[contest].p[problem-1].first == false) //該題尚未解過
v[contest].p[problem-1].second += 20; //增加懲罰時間
}
}
sort(v.begin(), v.end(), cmp);
for(auto a : v){
if(a.f){
if(a.pro == 0)
a.t = 0;
cout << a.con << " " << a.pro << " " << a.t << "\\n";
}
else
break;
}
if(t)
cout << "\\n";
}
return 0;
}