QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#707960 | #8230. Submissions | heyuhao | WA | 0ms | 18652kb | C++20 | 5.7kb | 2024-11-03 18:25:00 | 2024-11-03 18:25:02 |
Judging History
answer
#pragma GCC optimize(3, "Ofast", "inline")
#include <iostream>
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define INF 0x3f3f3f3f
#define L_INF 0x7f3f3f3f3f3f3f3f
#define db cout << "debug\n";
using namespace std;
const int Mod = 998244353;
using ll = long long;
struct submission
{
int num;
string name;
int time,pro;
bool zt;
}sub[100010];
int m;
bool cmp(submission a,submission b)
{
if(a.name!=b.name)
return a.name<b.name;
if(a.pro!=b.pro)
return a.pro<b.pro;
if(a.time!=b.time)
return a.time<b.time;
if(a.num!=b.num)
return a.num<b.num;
}
bool cmp1(pair<int,int> a,pair<int,int> b)
{
if(a.first!=b.first)
return a.first>b.first;
return a.second<b.second;
}
struct team
{
int guo,time;
string name;
}tea[100010];
bool cmp2(team a,team b)
{
if(a.guo!=b.guo)
return a.guo>b.guo;
return a.time<b.time;
}
pair<int,int> all[100010],all1[100010],all2[100010];
string dname[100010];
bool st[100010];
void solve()
{
int m;
cin>>m;
for(int i=1;i<=m;i++)
st[i]=false;
for(int i=1;i<=m;i++)
{
sub[i].num=i;
string c,p,s;
int t;
cin>>c>>p>>t>>s;
sub[i].name=c;
sub[i].pro=p[0]-'A';
sub[i].time=t;
if(s=="accepted")
sub[i].zt=true;
else
sub[i].zt=false;
}
if(m==1)
{
cout<<"1\n"<<sub[1].name<<"\n";
return;
}
sort(sub+1,sub+1+m,cmp);
// for(int i=1;i<=m;i++)
// cout<<sub[i].num<<" "<<sub[i].name<<" "<<sub[i].pro<<" "<<sub[i].time<<" "<<sub[i].zt<<"\n";
int pos=1; //下标
int sum=0,sumd=0,sume=0; //过一道题的队伍
while(pos<=m)
{
string name=sub[pos].name; //当前队名
bool flag=false; //是否过题
int guo=0,fa=0; //过题数和罚时
int best=500;
int best_more=1e9,best_less=0;
int worst_more=1e9,worst_less=0;
while(sub[pos].name==name&&pos<=m)
{
int pro=sub[pos].pro; //当前题目
bool flag1=false,flag2=false; //是否过题 是否最坏过题
int ti=0; //罚时
int mint=sub[pos].time;
int wor_fa=0;
// cout<<name<<" "<<pro<<" "<<mint<<"\n";
while(sub[pos].pro==pro&&sub[pos].name==name&&pos<=m)
{
if(sub[pos].zt&&flag1==false)
{
flag1=true;
ti+=sub[pos].time;
wor_fa+=20;
}
else if(!flag1)
ti+=20,wor_fa+=20;
else
if(flag1==true&&flag2==false)
{
if(sub[pos].zt)
{
flag2=true;
wor_fa+=sub[pos].time;
}
else
wor_fa+=20;
}
pos++;
}
if(flag1)
{
flag=true;
guo++;
fa+=ti;
// cout<<name<<" "<<pro<<" "<<best_less<<"\n";
best_less=max(best_less,ti-mint);
}
else
{
best_more=min(best_more,mint);
}
if(flag2)
{
worst_less=max(worst_less,wor_fa-ti);
}
else
{
worst_more=min(worst_more,ti);
// cout<<"1\n";
}
}
sumd++;
dname[sumd]=name;
if(best_more!=1e9)
all1[sumd].first=guo+1,all1[sumd].second=fa+best_more;
else
all1[sumd].first=guo,all1[sumd].second=fa-best_less;
sume++;
if(worst_more!=1e9)
{
all2[sume].first=guo-1,all2[sume].second=fa-worst_more;
}
else
all2[sume].first=guo,all[2].second=fa+worst_less;
// cout<<name<<" "<<guo<<" "<<fa<<"\n";
// cout<<all1[sumd].first<<" "<<all[sumd].second<<"\n";
if(flag)
{
sum++;
all[sum].first=guo;
all[sum].second=fa;
tea[sum].guo=guo;
tea[sum].time=fa;
tea[sum].name=name;
}
}
// for(int i=1;i<=sum;i++)
// cout<<all[i].first<<" "<<all[i].second<<"\n";
sort(all+1,all+1+sum,cmp1);
sort(all2+1,all2+1+sume,cmp1);
sort(tea+1,tea+1+sum,cmp2);
int gold=min(35,(sum+9)/10);
string jinw=tea[gold].name,jinw1=tea[gold+1].name;
int gstan=all[gold].first,tstand=all[gold].second;
// cout<<gstan<<" "<<tstand<<"\n";
if(gold%10==0)
{
string gname=tea[gold+1].name;
for(int i=1;i<=sumd;i++)
if(dname[i]==gname)
st[i]=true;
}
pos=1;
while(sub[pos].name!=jinw1)
{
pos++;
}
int jinwguo,ijnwt,jinwguo1,jinwt1;
{
string name=sub[pos].name; //当前队名
bool flag=false; //是否过题
int guo=0,fa=0; //过题数和罚时
int best=500;
int best_more=500,best_less=0;
while(sub[pos].name==name&&pos<=m)
{
int pro=sub[pos].pro; //当前题目
bool flag1=false; //是否过题
int ti=0; //罚时
int mint=sub[pos].time;
// cout<<name<<" "<<pro<<" "<<mint<<"\n";
while(sub[pos].pro==pro&&sub[pos].name==name&&pos<=m)
{
if(sub[pos].zt)
{
flag1=true;
ti+=sub[pos].time;
}
else if(!flag1)
ti+=20;
pos++;
}
if(flag1)
{
flag=true;
guo++;
fa+=ti;
// cout<<name<<" "<<pro<<" "<<best_less<<"\n";
best_less=max(best_less,ti-mint);
}
else
{
best_more=min(best_more,mint);
}
}
jinwguo1=guo;
jinwt1=fa;
}
// cout<<jinw1<<" "<<jinwguo1<<" "<<jinwt1<<"\n";
// cout<<all2[1].first<<" "<<all[1].second<<"\n";
if(jinwguo1>all2[gold].first||jinwguo1==all2[gold].first&&jinwt1<=all2[gold].second)
{
for(int i=1;i<=sumd;i++)
if(dname[i]==jinw1)
st[i]=true;
}
int ans=0;
for(int i=1;i<=sumd;i++)
if(all1[i].first>gstan||all1[i].first==gstan&&all1[i].second<=tstand)
st[i]=true;
for(int i=1;i<=sumd;i++)
if(st[i])
ans++;
cout<<ans<<"\n";
for(int i=1;i<=sumd;i++)
if(st[i])
cout<<dname[i]<<" ";
cout<<"\n";
}
int main()
{
IOS;
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
#ifndef ONLINE_JUDGE
clock_t start_time = clock();
#endif
int t;
t = 1;
cin >> t;
while (t--)
{
solve();
}
#ifndef ONLINE_JUDGE
cout << "Used " << (double)(clock() - start_time) << " ms" << endl;
#endif
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 18496kb
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 TS1 TSxingxing10 4 AllWayTheNorth ImYourFan LetItRot XuejunXinyoudui1
result:
ok 2 test cases ok. (2 test cases)
Test #2:
score: 0
Accepted
time: 0ms
memory: 18384kb
input:
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
output:
2 jiangly jiangly_fan 1 conqueror_of_tourist
result:
ok 2 test cases ok. (2 test cases)
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 18652kb
input:
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 a...
output:
1 A 1 A
result:
wrong answer the numbers are different in the case 1. (test case 1)