QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#711131 | #8230. Submissions | heyuhao | WA | 3ms | 15392kb | C++20 | 7.9kb | 2024-11-05 00:48:16 | 2024-11-05 00:48:16 |
Judging History
answer
#pragma GCC optimize(3, "Ofast", "inline")
#include <iostream>
#include<map>
#include<vector>
#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;
unordered_map<string,int> tname;
unordered_map<string,int> ans,ans1;
int pos,m,sum_team;
int t,tt;
struct submission
{
int num;
string name;
int time,pro;
bool zt;
}sub[100010];
bool cmp(const submission& a, const submission& b) {
return std::tie(a.name, a.pro, a.time, a.num) < std::tie(b.name, b.pro, b.time, b.num);
}
struct problem
{
int num_sub=0,sum_time=0,less_time=0;
bool flag=false;
int index;
};
struct team
{
string name;
int guo,fa;
// int start,end;
vector<problem> pro;
}tea[100010];
bool cmp1(pair<pair<int,int>,string> a,pair<pair<int,int>,string> b)
{
if(a.first.first!=b.first.first)
return a.first.first>b.first.first;
return a.first.second<b.first.second;
}
void solve()
{
ans.clear();
ans1.clear();
int m;
cin>>m;
tname.clear();
sum_team=0;
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";
cout<<sub[1].name<<"\n";
return;
}
sort(sub+1,sub+1+m,cmp);
pos=1;
while(pos<=m)
{
string name=sub[pos].name; //当前队名
tname[name]=++sum_team;
bool flag=false; //是否过题
int guo=0,fa=0; //过题数和罚时
tea[sum_team].name=name;
tea[sum_team].pro.clear();
while(sub[pos].name==name&&pos<=m)
{
problem x;
x.index=sub[pos].pro;
x.less_time=sub[pos].time;
int pro=sub[pos].pro; //当前题目
bool flag1=false; //是否过题
int ti=0; //罚时
// cout<<name<<" "<<pro<<" "<<mint<<"\n";
while(sub[pos].pro==pro&&sub[pos].name==name&&pos<=m)
{
if(!flag1)
x.num_sub++;
if(sub[pos].zt&&flag1==false)
{
flag1=true;
ti+=sub[pos].time;
}
else if(!flag1)
ti+=20;
pos++;
}
x.flag=flag1;
if(flag1)
{
flag=true;
x.sum_time=ti;
guo++;
fa+=ti;
}
tea[sum_team].pro.push_back(x);
}
tea[sum_team].guo=guo;
tea[sum_team].fa=fa;
}
int stdguo=0,stdfa=0;
int stasum=0; //原本有效参赛队数量
vector<pair<pair<int,int>,string>> all;
for(int j=1;j<=sum_team;j++)
if(tea[j].guo>0)
all.push_back({{tea[j].guo,tea[j].fa},tea[j].name});
int ssum=all.size();
int gold=min(35,(ssum+9)/10);
if(all.size())
{
sort(all.begin(),all.end(),cmp1);
stasum=ssum;
// cout<<ssum<<"\n";
int stguo=all[gold-1].first.first,stfa=all[gold-1].first.second;
stdguo=stguo;
stdfa=stfa;
for(auto c:all)
{
if(c.first.first>stguo||c.first.first==stguo&&c.first.second<=stfa)
ans[c.second]=1,ans1[c.second]=1;
}
}
int num_gold=ans1.size();
bool flag6=false,flag7=false;
if(stasum%10!=0)
flag6=true;
if(stasum%10!=1)
flag7=true;
for(int i=1;i<=m;i++)
{
pos=tname[sub[i].name];
string name=sub[i].name;
int index=sub[i].pro;
int shun=sub[i].num;
int l=i,r=i;
if(sub[i].zt&&!ans1.count(name))
continue;
if(sub[i].zt==false&&ans.count(name)&&(flag6||tea[pos].guo>0))
continue;
while(l>0&&sub[l].name==name&&sub[l].pro==index)
l--;
while(r<=m&&sub[r].name==name&&sub[r].pro==index)
r++;
l++;
r--;
bool flag5=false;
int xinti=0;
for(int j=l;j<=r;j++)
{
bool zt=sub[j].zt;
if(sub[j].num==shun)
zt=1-zt;
if(zt&&flag5==false)
{
flag5=true;
xinti+=sub[j].time;
}
else if(!flag5)
{
xinti+=20;
}
}
int xinguo=0,xinfa=0;
for(auto c:tea[pos].pro)
{
if(c.index==index)
{
if(flag5)
{
xinguo++;
xinfa+=xinti;
}
}
else
{
if(c.flag)
{
xinguo++;
xinfa+=c.sum_time;
}
}
}
// cout<<gold<<" "<<all.size()<<"***\n";
if(ans1.count(name))
{
if((xinguo<stdguo||xinguo==stdguo&&xinfa>stdfa))
{
if(gold==1)
continue;
if(!((gold<all.size()&&(xinguo>all[gold].first.first||xinguo==all[gold].first.first&&xinfa<all[gold].first.second))||num_gold!=gold))
if(!(flag7==false&&xinguo==0))
if(gold<all.size())
{
int liguo=all[gold].first.first,lifa=all[gold].first.second;
for(int i=gold;i<ssum;i++)
{
if(all[i].first.first==liguo&&all[i].first.second==lifa)
ans[all[i].second]=1;
else
break;
}
}
else if(gold)
{
// cout<<"***\n";
int liguo=xinguo,lifa=xinfa;
// cout<<liguo<<" "<<lifa<<"\n";
if(xinguo>0)
for(int i=gold;i<ssum;i++)
{
if(all[i].first.first==liguo&&all[i].first.second==lifa)
ans[all[i].second]=1;
else
break;
}
}
}
}
else if(tea[pos].guo>0)
{
if(xinguo>stdguo||xinguo==stdguo&&xinfa<=stdfa)
ans[name]=1;
}
else if(flag6==false)
{
if(gold<all.size())
{
// cout<<"***\n";
int liguo=all[gold].first.first,lifa=all[gold].first.second;
// cout<<liguo<<" "<<lifa<<"***\n";
if(xinguo>liguo||xinguo==liguo&&xinfa<lifa)
ans[name]=1;
else
{
if(liguo==1&&lifa==xinfa)
ans[name]=1;
for(int i=gold;i<ssum;i++)
{
if(all[i].first.first==liguo&&all[i].first.second==lifa)
ans[all[i].second]=1;
else
break;
}
}
}
else
{
ans[name]=1;
}
}
else
{
if(xinguo>stdguo||xinguo==stdguo&&xinfa<=stdfa)
ans[name]=1;
}
}
cout<<ans.size()<<"\n";
for(auto s:ans)
{
cout<<s.first<<" ";
}
cout<<"\n";
}
int main()
{
IOS;
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
// int t;
t = 1;
cin >> t;
tt=t;
while (t--)
{
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 15336kb
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 4 XuejunXinyoudui1 LetItRot ImYourFan AllWayTheNorth
result:
ok 2 test cases ok. (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 3ms
memory: 15392kb
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:
1 jiangly_fan 1 conqueror_of_tourist
result:
wrong answer the numbers are different in the case 1. (test case 1)