对拍拍不出来了
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define sort stable_sort
#define endl '\n'
struct submit
{
int tim,state,problem;
bool operator < (const submit &another) const
{
return (problem==another.problem)?tim<another.tim:problem<another.problem;
}
};
struct team
{
int acsum,penalty,order=0,cnt[27];
string name;
deque<submit>roll;
bool operator < (const team &another) const
{
if(acsum!=another.acsum)
{
return acsum>another.acsum;
}
return (penalty==another.penalty)?order<another.order:penalty<another.penalty;
}
bool operator > (const team &another) const
{
if(acsum!=another.acsum)
{
return acsum>another.acsum;
}
return (penalty==another.penalty)?order<another.order:penalty<another.penalty;
}
}e[200010],tmp;
unordered_map<string,int>f;
priority_queue<team>q;
int get_tim()
{
int x,y,z;
char pd;
cin>>x>>pd>>y>>pd>>z;
return x*3600+y*60+z;
}
int get_problem(char x)
{
return x-'A'+1;
}
void work(team &x,int tim,int state,int problem)
{
if(x.cnt[problem]!=-1)
{
if(state==1)
{
x.acsum++;
x.penalty+=x.cnt[problem]*1200+tim;
x.cnt[problem]=-1;
}
else
{
x.cnt[problem]++;
}
}
}
void read(int &cnt)
{
char c;
string name,pd;
int tim=get_tim();
cin>>c>>name;
getline(cin,pd);
int state=(pd[1]=='A');
int problem=get_problem(c);
if(f.find(name)==f.end())
{
cnt++;
f[name]=cnt;
e[f[name]].order=cnt;
e[f[name]].name=name;
}
if(tim<=14400)
{
// cout<<tim<<" "<<state<<" "<<problem<<" "<<name<<endl;
// work(e[f[name]],tim,state,problem);
if(e[f[name]].cnt[problem]!=-1)
{
if(state==1)
{
e[f[name]].acsum++;
e[f[name]].penalty+=e[f[name]].cnt[problem]*1200+tim;
e[f[name]].cnt[problem]=-1;
}
else
{
e[f[name]].cnt[problem]++;
}
}
}
else
{
// cout<<f[name]<<" "<<tim<<" "<<state<<" "<<problem<<" "<<name<<endl;
e[f[name]].roll.push_back((submit){tim,state,problem});
}
}
int main()
{
// #define Isaac
#ifdef Isaac
freopen("in.in","r",stdin);
freopen("out.out","w",stdout);
#endif
int n,m,k,cnt=0,i;
cin>>n>>m>>k;
for(i=1;i<=k;i++)
{
read(cnt);
}
for(i=1;i<=cnt;i++)
{
sort(e[i].roll.begin(),e[i].roll.end());
q.push(e[i]);
// cout<<e[i].name<<endl;
// for(int j=0;j<e[i].roll.size();j++)
// {
// cout<<e[i].roll[j].problem<<" "<<e[i].roll[j].state<<" "<<e[i].roll[j].tim<<endl;
// }
// cout<<endl;
}
while(q.empty()==0)
{
tmp=q.top();
q.pop();
cout<<tmp.name<<endl;
// cout<<tmp.name<<" "<<tmp.acsum<<" "<<tmp.penalty<<endl;
if(q.empty()==0)
{
// cout<<"nxt "<<q.top().name<<" "<<q.top().acsum<<" "<<q.top().penalty<<endl;
while(tmp.roll.empty()==0&&q.top()>tmp)
{
int problem=tmp.roll.front().problem;
int state=tmp.roll.front().state;
int tim=tmp.roll.front().tim;
if(tmp.cnt[problem]!=-1)
{
if(state==1)
{
// cout<<tmp.name<<" "<<state<<endl;
tmp.acsum++;
tmp.penalty+=tmp.cnt[problem]*1200+tim;
tmp.cnt[problem]=-1;
}
else
{
tmp.cnt[problem]++;
}
}
// work(tmp,tmp.roll.front().tim,tmp.roll.front().state,tmp.roll.front().problem);
tmp.roll.pop_front();
}
if(tmp>q.top())
{
// cout<<tmp.roll.size()<<endl;
q.push(tmp);
}
// cout<<"add "<<tmp.name<<" "<<tmp.acsum<<" "<<tmp.penalty<<endl;
}
}
return 0;
}