我已经挑不出毛病了,但还是10分啊!!!
查看原帖
我已经挑不出毛病了,但还是10分啊!!!
1045301
Hamburger999楼主2024/2/15 12:37

code:

#include<bits/stdc++.h> 
using namespace std;

struct team{
	string name;
	int tongguo,fashi,fir;
	int fb[26],ac[26],wa[26],lst[26];
	friend bool operator>(team a,team b){
		if(a.tongguo!=b.tongguo)return a.tongguo>b.tongguo;
		else if(a.fashi!=b.fashi)return a.fashi<b.fashi;
		return a.fir<b.fir;
	}
}a[200001];

priority_queue<team,vector<team>,greater<team> > pq;
unordered_map<string,int> mp;
int top,n,m,k;

int main(){
	cin>>n>>m>>k;
	for(int i=1;i<=k;i++){
		int xx,yy,zz;
		char ti;
		string name,ac;
		scanf("%d:%d:%d %c",&xx,&yy,&zz,&ti); 
		cin>>name;
		getline(cin,ac);
		if(!mp.count(name)) a[++top].name=name,mp[name]=top,a[top].fir=xx*3600+yy*60+zz;
		if(xx*3600+yy*60+zz>14400)a[mp[name]].fb[ti-'A']=1;
		if(ac[1]=='A'){
			if(a[mp[name]].ac[ti-'A']==1)continue;
			a[mp[name]].ac[ti-'A']=1;
			a[mp[name]].lst[ti-'A']=xx*60+yy;
			if(a[mp[name]].fb[ti-'A']==0){
				++a[mp[name]].tongguo;
				a[mp[name]].fashi+=xx*60+yy+a[mp[name]].wa[ti-'A']*20;
			}
		}
		else{
			if(a[mp[name]].ac[ti-'A']==0)a[mp[name]].wa[ti-'A']++;
		}
	}
	for(int i=1;i<=top;i++){
		pq.push(a[i]);
	}
	while(pq.size()>=2){
		team tp1=pq.top();pq.pop();
		team tp2=pq.top();pq.pop();
		cout<<tp1.name<<endl;
		for(int i=0;i<n;i++){
			if(tp1.fb[i]==1){
				if(tp1.ac[i]==1){
					tp1.tongguo++;
					tp1.fashi+=tp1.lst[i]+tp1.wa[i]*20;
					tp1.fb[i]=0;
					if(tp1>tp2){
						pq.push(tp1);
						break;
					}
				}
			}
		}
		pq.push(tp2);
	}
	cout<<pq.top().name;
}
2024/2/15 12:37
加载中...