思路就是存两个结构体,一个解决输入,一个解决输出,没想到最后两个测试点过不了。
#include <bits/stdc++.h>
//粘贴复制至头文件下即可
#pragma once
#pragma GCC diagnostic error "-std=c++11"
#pragma GCC target("avx")
#pragma GCC optimize(2)
#pragma GCC optimize(3,"Ofast","inline")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
typedef long long ll;
using namespace std;
const int N = 1e5 + 10;
struct node {
string id;
int score;
string sch;
} a[N];
struct nodes {
int rank;
string sch;
double sscore;
int people;
int ssscore;
} b[N];
int n;
string s;
int cnt = 0;
map<string, int> mp;
bool cmp(nodes x, nodes y) {
if (x.ssscore != y.ssscore)
return x.ssscore > y.ssscore;
else if (x.people != y.people)
return x.people < y.people;
else if (x.sch != y.sch)
return x.sch < y.sch;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
for (int i = 1; i <= n; i ++) {
cin >> a[i].id >> a[i].score >> s;
for (int j = 0; j < s.size(); j++)
s[j] = tolower(s[j]);
a[i].sch = s;
}
for (int i = 1; i <= n; i ++) {
if (!mp[a[i].sch]) {
b[++cnt].sch = a[i].sch;
mp[a[i].sch] = 1;
string t = a[i].id;
if (t[0] == 'A')
b[cnt].sscore += (a[i].score);
else if (t[0] == 'T')
b[cnt].sscore += (1.5 * a[i].score);
else if (t[0] == 'B')
b[cnt].sscore += ( 1.0 * a[i].score / 1.5);
b[cnt].people++;
for (int j = i + 1; j <= n ; j++) {
if (a[i].sch == a[j].sch) {
string t = a[j].id;
if (t[0] == 'A')
b[cnt].sscore += (a[j].score);
else if (t[0] == 'T')
b[cnt].sscore += (1.5 * a[j].score);
else if (t[0] == 'B')
b[cnt].sscore += ( 1.0 * a[j].score / 1.5);
b[cnt].people++;
}
}
}
}
for (int i = 1; i <= cnt; i ++)
b[i].ssscore = floor(b[i].sscore);
sort(b + 1, b + cnt + 1, cmp);
cout << cnt << endl;
int num = 0;
int lastscore = -1;
for (int i = 1; i <= cnt; i++) {
if (b[i].ssscore != lastscore)
num = i;
lastscore = b[i].ssscore;
printf("%d %s %d %d\n", num, b[i].sch.c_str(), b[i].ssscore, b[i].people);
}
return 0;
}