QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#757108 | #8230. Submissions | RWeakest | WA | 5ms | 19388kb | C++20 | 9.9kb | 2024-11-17 00:17:30 | 2024-11-17 00:17:30 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2e5 + 100;
ll T, n, m;
double havepass;
string name[N];
string str, state;
ll temp;
char pi;
struct node {
ll ti, p;
bool st;
node(ll ti_ = 0, ll p_ = 0, bool st_ = false) {
ti = ti_, p = p_, st = st_;
}
};
struct score {
ll no, num, sum_ti;
score(ll no_ = 0, ll num_ = 0, ll sum_ti_ = 0) {
no = no_, num = num_, sum_ti = sum_ti_;
}
};
score team[N];
bool cmp(score s1, score s2) {
if (s1.num != s2.num) return s1.num > s2.num;
return s1.sum_ti < s2.sum_ti;
}
bool better(score s1, score s2) {
if (s1.num != s2.num) return s1.num > s2.num;
return s1.sum_ti <= s2.sum_ti;
}
vector<node> tj[N][30];
ll first[N][30], pena[N], passed[N], wrong[N][30];
bool can[N];
score zuicha(int p) {
ll pen = pena[p], pas = passed[p];
score badest = score(p, pas, pen);
for (int i = 0; i < 26; i++) {
for (int j = 0; j < tj[p][i].size(); j++) {
if (tj[p][i][j].st) {
int nxttime = -1;
for (int l = j + 1; l < tj[p][i].size(); l++) {
if (tj[p][i][l].st) {
nxttime = l;
break;
}
}
score chi = score(p, 0, 0);
if (nxttime == -1) {
chi = score(p, pas - 1ll, pen - first[p][i] - wrong[p][i]);
} else {
chi = score(p, pas, pen - first[p][i] - wrong[p][i] + tj[p][i][nxttime].st + nxttime * 20);
}
if (better(badest, chi)) badest = chi;
break;
}
}
}
return badest;
}
score zuicha_just(int p) {
ll pen = pena[p], pas = passed[p];
score badest = score(p, pas, pen);
for (int i = 0; i < 26; i++) {
for (int j = 0; j < tj[p][i].size(); j++) {
if (tj[p][i][j].st) {
int nxttime = -1;
for (int l = j + 1; l < tj[p][i].size(); l++) {
if (tj[p][i][l].st) {
nxttime = l;
break;
}
}
score chi = score(p, 0, 0);
if (nxttime == -1) {
chi = score(p, pas - 1ll, pen - first[p][i] - wrong[p][i]);
} else {
chi = score(p, pas, pen - first[p][i] - wrong[p][i] + tj[p][i][nxttime].st + nxttime * 20);
}
if (chi.num == badest.num && better(badest, chi)) badest = chi;
break;
}
}
}
return badest;
}
score zuihao(int p) {
ll pen = pena[p], pas = passed[p];
score goodest = score(p, pas, pen);
for (int i = 0; i < 26; i++) {
for (int j = 0; j < tj[p][i].size() && j < 1; j++) {
if (!tj[p][i][j].st) {
score chi = score(p, 0, 0);
if (first[p][i] == -1) {
chi = score(p, pas + 1ll, pen + tj[p][i][j].ti);
} else {
chi = score(p, pas, pen - first[p][i] + tj[p][i][j].ti - wrong[p][i]);
}
if (better(chi, goodest)) goodest = chi;
break;
}
}
}
return goodest;
}
score just(int p) {
score jus = score(p, 2e5, 2e5);
for (int i = 0; i < 26; i++) {
for (int j = 0; j < tj[p][i].size(); j++) {
score chi = score(p, 1ll, tj[p][i][j].ti + j * 20ll);
if (better(jus, chi)) jus = chi;
}
}
return jus;
}
void solve() {
cin >> m;
n = 0, havepass = 0;
map<string, ll> mp;
mp.clear();
for (int i = 1; i <= m; i++) {
cin >> str >> pi >> temp >> state;
if (!mp[str]) {
n++;
mp[str] = n;
name[n] = str;
}
bool nowst = false;
if (state[0] == 'a') nowst = true;
tj[mp[str]][pi - 'A'].emplace_back(temp, pi - 'A', nowst);
}
//begin
for (int i = 1; i <= n; i++) {
for (int j = 0; j < 26; j++)
first[i][j] = -1, wrong[i][j] = 0;
pena[i] = passed[i] = 0;
can[i] = false;
}
for (int i = 1; i <= n; i++) {
for (int j = 0; j < 26; j++) {
for (auto l: tj[i][j]) {
if (!l.st) wrong[i][j] += 20;
else {
first[i][j] = l.ti;
passed[i]++;
pena[i] += l.ti;
pena[i] += wrong[i][j];
break;
}
}
if (first[i][j] == -1) wrong[i][j] = 0;
}
if (passed[i] > 0) havepass++;
team[i] = score(i, passed[i], pena[i]);
}
sort(team + 1, team + 1 + n, cmp);
//gold_num
ll goldnum = min(ceil(0.1 * havepass), 35.0);
ll gdp = goldnum;
while (gdp < n && team[gdp + 1].num == team[gdp].num && team[gdp + 1].sum_ti == team[gdp].sum_ti) gdp++;
for (int i = 1; i <= gdp; i++) can[team[i].no] = true;
//test_out
// cout << gdp << " gdp\n";
// for (int i = 1; i <= n; i++) {
// printf("team:%d %s num:%lld pena:%lld\n", i, name[team[i].no].c_str(), team[i].num, team[i].sum_ti);
// for (int j = 0; j < 26; j++) {
// for (auto l: tj[i][j]) {
// printf("p:%lld ti:%lld st:%d\n", l.p, l.ti, l.st);
// }
// }
// }
//silver_first
if (gdp != n) {
bool can_s_f_1 = false, can_s_f_2 = false;
//havepass++
score worst1 = score(1, 2e5, 2e5);
if (min(ceil(0.1 * (havepass + 1)), 35.0) > gdp) {
// printf("havr pass may ++\n");
for (int i = gdp + 1; i <= n; i++) {
if (passed[team[i].no] == 0) {
score best = just(team[i].no);
if (best.num == 1) {
can_s_f_1 = true;
if (better(worst1, best))
worst1 = best;
}
}
}
}
//gold--
bool maydec = false;
if (min(ceil(0.1 * (havepass - 1)), 35.0) < gdp)
maydec = true;
for (int i = 1; i <= gdp; i++) {
score worst = zuicha(team[i].no);
if (better(team[gdp + 1], worst) && (worst.num != 0 || !maydec)) can_s_f_2 = true;
score wr2 = zuicha_just(team[i].no);
if (better(team[gdp + 1], wr2)) can_s_f_2 = true;
}
// printf("can_s_f %d %d\n", can_s_f_1, can_s_f_2);
if (can_s_f_1) {
for (int i = gdp + 1; i <= n; i++) {
if (team[i].num == 0 && better(zuihao(team[i].no), team[gdp + 1])) can[team[i].no] = true;
}
// printf("worst1 %lld %lld %lld\n", worst1.no, worst1.num, worst1.sum_ti);
if (better(team[gdp + 1], worst1)) {
// printf("can s_f_1\n");
int nowp = gdp + 1;
can[team[gdp + 1].no] = true;
while (nowp < n && better(team[nowp + 1], team[nowp])) {
nowp++;
can[team[nowp].no] = true;
}
}
}
if (can_s_f_2) {
int nowp = gdp + 1;
can[team[gdp + 1].no] = true;
while (nowp < n && better(team[nowp + 1], team[nowp])) {
nowp++;
can[team[nowp].no] = true;
}
}
}
//not_gold
for (int i = gdp + 1; i <= n; i++) {
if (better(zuihao(team[i].no), team[gdp])) can[team[i].no] = true;
}
//WTF
//if (havepass == 1 && zuicha(team[1].no).num == 0)
// for (int i = 1; i <= n; i++) can[i] = true;
//output
ll allcan = 0;
for (int i = 1; i <= n; i++) if (can[i]) allcan++;
cout << allcan << "\n";
for (int i = 1; i <= n; i++) if (can[i]) cout << name[i] << " ";
cout << "\n";
//clear
for (int i = 1; i <= n; i++) {
for (int j = 0; j < 26; j++) {
tj[i][j].clear();
}
}
mp.clear();
for (int i = 1; i <= n; i++) can[i] = false;
for (int i = 1; i <= n; i++) team[i] = score(0, 0, 0);
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr), std::cout.tie(nullptr);
cin >> T;
while (T--) {
solve();
}
return 0;
}
/*
2
5
TSxingxing10 G 0 rejected
TSxingxing10 B 83 accepted
aoliaoligeiliao J 98 accepted
TS1 J 118 accepted
TS1 B 263 accepted
12
AllWayTheNorth A 0 rejected
YaoYaoLingXian Y 10 accepted
XuejunXinyoudui1 X 200 rejected
XuejunXinyoudui1 X 200 accepted
LetItRot L 215 accepted
AllWayTheNorth W 250 accepted
ImYourFan I 257 accepted
ImYourFan Y 257 accepted
AllWayTheNorth T 264 accepted
XuejunXinyoudui1 J 294 accepted
LetItRot I 299 accepted
LetItRot I 299 rejected
2
2
jiangly_fan A 1 accepted
jiangly B 23 accepted
3
conqueror_of_tourist A 1 accepted
conqueror_of_tourist A 2 accepted
tourist B 23 accepted
2
13
A A 1 accepted
A X 1 accepted
K K 1 rejected
B B 2 accepted
C C 2 accepted
D D 2 accepted
E E 2 accepted
F F 2 accepted
G G 2 accepted
H H 2 accepted
I I 2 accepted
J J 2 accepted
K K 2 rejected
12
A A 1 accepted
A X 1 accepted
B B 2 accepted
C C 2 accepted
D D 2 accepted
E E 2 accepted
F F 2 accepted
G G 2 accepted
H H 2 accepted
I I 2 accepted
J J 2 rejected
K K 2 rejected
2
11
A A 1 accepted
B B 1 accepted
C C 2 accepted
D D 2 accepted
E E 2 accepted
F F 2 accepted
G G 2 accepted
H H 2 accepted
I I 2 accepted
J J 2 accepted
K K 2 accepted
12
A A 1 accepted
A X 1 accepted
K K 1 rejected
B B 2 accepted
C C 2 accepted
D D 2 accepted
E E 2 accepted
F F 2 accepted
G G 2 accepted
H H 2 accepted
I I 2 accepted
J J 2 accepted
*/
詳細信息
Test #1:
score: 0
Wrong Answer
time: 5ms
memory: 19388kb
input:
2 5 TSxingxing10 G 0 rejected TSxingxing10 B 83 accepted aoliaoligeiliao J 98 accepted TS1 J 118 accepted TS1 B 263 accepted 12 AllWayTheNorth A 0 rejected YaoYaoLingXian Y 10 accepted XuejunXinyoudui1 X 200 rejected XuejunXinyoudui1 X 200 accepted LetItRot L 215 accepted AllWayTheNorth W 250 accept...
output:
2 TSxingxing10 TS1 5 AllWayTheNorth YaoYaoLingXian XuejunXinyoudui1 LetItRot ImYourFan
result:
wrong answer the numbers are different in the case 2. (test case 2)