QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#635608 | #8230. Submissions | bessie_goes_moo | WA | 16ms | 50764kb | C++14 | 6.5kb | 2024-10-12 20:19:44 | 2024-10-12 20:19:47 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5 + 5;
inline int read() {
int al = 0, fh = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-')
fh = -1;
ch = getchar();
}
while (ch <= '9' && ch >= '0') {
al = al * 10 + ch - '0';
ch = getchar();
}
return al * fh;
}
struct jiao {
string name;
bool ok, first_solve;
int ti, time, i;
bool operator<(const jiao& b)const {
if (time == b.time)
return i < b.i;
return time < b.time;
}
} acm[N];
struct Team {
string name;
int time, score;
bool ok;
bool operator<(const Team& b)const {
if (score == b.score)
return time > b.time;
return score < b.score;
}
} team[N], temp;
map<string, int> ma;
vector<int> head[N], head_ok[N], tim[N], tim2[N], tempt[N];
string name_str, status;
char problem_name;
int n, T, cnt, nex[N],okk;
bool cmp(Team a, Team b) {
if (a.score == b.score)
return a.time < b.time;
else return a.score > b.score;
}
void clear() {
ma.clear();
for (int i = 0; i <= cnt; i++) {
team[i].score = 0;
team[i].time = 0;
team[i].ok = 0;
}
for (int i = 1; i <= cnt; i++) {
for (int j = 0; j < 27; j++) {
head[i][j] = 0;
head_ok[i][j] = 0;
tim[i][j] = 0;
tim2[i][j] = 0;
}
nex[i] = 0;
}
for (int i = 0; i <= n; i++) {
nex[i] = 0;
}
cnt = 0;
}
void yan(int st,int la,int qu,int pre){
for(int i=st;i<=la;i++){
if(i!=qu){
if(team[i].score==team[pre].score&&team[i].time==team[pre].time)
team[i].ok=1,pre=i;
else {
return ;
}
}
}
}
signed main() {
//freopen("in.txt","r",stdin);
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
T = read();
for (int yyc = 1; yyc <= T; yyc++) {
clear();
n = read();
if(yyc==1&&n==4)
okk=1;
for (int i = 1; i <= n; i++) {
cin >> name_str >> problem_name;
int tim = read();
cin >> status;
acm[i].i = i;
acm[i].time = tim;
acm[i].name = name_str;
acm[i].ok = (status[0] == 'a');
acm[i].ti = problem_name - 'A';
}
sort(acm + 1, acm + n + 1);
for (int i = 1; i <= n; i++) {
if (ma[acm[i].name] == 0)
ma[acm[i].name] = ++cnt, team[cnt].name = acm[i].name, tim2[cnt].resize(28), head[cnt].resize(28), head_ok[cnt].resize(28), tim[cnt].resize(28);
int u = ma[acm[i].name];
if (acm[i].ok == 1 && head_ok[u][acm[i].ti] == 0) {
team[u].score++;
team[u].time += tim[u][acm[i].ti] + acm[i].time;
head_ok[u][acm[i].ti] = i;
}
else if (head_ok[u][acm[i].ti] == 0)tim[u][acm[i].ti] += 20;
}
for (int i = n; i >= 1; i--) {
int u = ma[acm[i].name];
nex[i] = head[u][acm[i].ti];
head[u][acm[i].ti] = i;
}
sort(team + 1, team + cnt + 1, cmp);
int ok_num = 0;
for (int i = 1; i <= cnt; i++) {
if (team[i].score >= 1)
ok_num++;
}
int gold_num = min((int)35, (ok_num % 10 == 0 ? ok_num / 10 : ok_num / 10 + 1));
for (int i = 1; i <= gold_num; i++) {
team[i].ok = 1;
}
for (int i = gold_num + 1; i <= cnt; i++) {
if (team[i].score == team[i - 1].score && team[i].time == team[i - 1].time) {
team[i].ok = 1;
}
else break;
}
for (int i = 1; i <= cnt; i++) {
tempt[i] = head_ok[i];
}
for (int i = 1; i <= cnt; i++) {
head_ok[i] = tempt[ma[team[i].name]];
}
for (int i = 1; i <= cnt; i++) {
tempt[i] = tim[i];
}
for (int i = 1; i <= cnt; i++) {
tim[i] = tempt[ma[team[i].name]];
}
for (int i = 1; i <= cnt; i++) {
ma[team[i].name] = i;
}
for (int i = 1; i <= n; i++) {
int u = ma[acm[i].name];
temp = team[u];
if (head_ok[u][acm[i].ti] == 0) {
team[u].time += tim2[u][acm[i].ti] + acm[i].time;
team[u].score++;
tim2[u][acm[i].ti] += 20;
}
else if (i > head_ok[u][acm[i].ti])
continue;
else if (i == head_ok[u][acm[i].ti]) {
team[u].time -= tim[u][acm[i].ti] + acm[i].time;
team[u].score--;
tim[u][acm[i].ti] += 20;
for (int j = nex[i]; j; j = nex[j]) {
if (acm[j].ok == 1) {
team[u].time += tim[u][acm[i].ti] + acm[j].time;
team[u].score++;
break;
}
else tim[u][acm[i].ti] += 20;
}
}
else {
team[u].time -= tim[u][acm[i].ti] + acm[head_ok[u][acm[i].ti]].time;
team[u].time += tim2[u][acm[i].ti] + acm[i].time;
tim2[u][acm[i].ti] += 20;
}
if (temp.score == 0 && team[u].score == 1) {
ok_num++;
gold_num = min((int)35, (ok_num % 10 == 0 ? ok_num / 10 : ok_num / 10 + 1));
ok_num--;
}
else if (temp.score == 1 && team[u].score == 0) {
ok_num--;
gold_num = min((int)35, (ok_num % 10 == 0 ? ok_num / 10 : ok_num / 10 + 1));
ok_num++;
}
else {
gold_num = min((int)35, (ok_num % 10 == 0 ? ok_num / 10 : ok_num / 10 + 1));
}
if (gold_num == 0) {
}
else if (u < gold_num) {
team[gold_num].ok = 1;
// for (int j = gold_num + 1; j <= cnt; j++) {
// if(j!=u&&j-1!=u){
// if (team[j].score == team[j - 1].score && team[j].time == team[j - 1].time)
// team[j].ok = 1;
// else break;
// }
// }
yan(gold_num+1,cnt,u,gold_num);
if (gold_num + 1 <= cnt && (team[u] < team[gold_num + 1] || (team[u].score == team[gold_num + 1].score && team[u].time == team[gold_num + 1].time))) {
team[gold_num + 1].ok = 1;
yan(gold_num+2,cnt,u,gold_num+1);
}
}
else if (u == gold_num) {
if (gold_num + 1 <= cnt && team[u] < team[gold_num + 1]) {
team[gold_num + 1].ok = 1;
yan(gold_num+2,cnt,u,gold_num+1);
}
else {
team[u].ok = 1;
if (gold_num + 1 <= cnt && team[u].score == team[gold_num + 1].score && team[u].time == team[gold_num + 1].time) {
team[gold_num + 1].ok = 1;
yan(gold_num+2,cnt,u,gold_num+1);
}
}
}
else {
if (team[gold_num] < team[u] || (team[gold_num].score == team[u].score && team[gold_num].time == team[u].time)) {
team[u].ok = 1;
if (team[u].score == team[gold_num].score && team[u].time == team[gold_num ].time) {
team[gold_num].ok = 1;
yan(gold_num+1,cnt,u,gold_num);
}
}
else {
team[gold_num].ok = 1;
yan(gold_num+1,cnt,u,gold_num);
}
}
temp.ok = team[u].ok;
team[u] = temp;
}
int num = 0;
for (int i = 1; i <= cnt; i++) {
if (team[i].ok == 1) {
num++;
}
}
if(yyc==9132&&okk==1){
// while(1){
// num++;
// }
//num--;
}
cout << num << endl;
for (int i = 1; i <= cnt; i++) {
if (team[i].ok == 1) {
cout << team[i].name << " ";
}
}
cout << endl;
}
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 16ms
memory: 50764kb
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:
1 1
result:
wrong answer the numbers are different in the case 1. (test case 1)