QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#368297#8230. SubmissionsliswtWA 12ms91956kbC++204.5kb2024-03-26 23:11:002024-03-26 23:11:01

Judging History

你现在查看的是最新测评结果

  • [2024-05-20 23:50:57]
  • hack成功,自动添加数据
  • (/hack/623)
  • [2024-05-20 23:48:44]
  • hack成功,自动添加数据
  • (/hack/622)
  • [2024-03-26 23:11:01]
  • 评测
  • 测评结果:WA
  • 用时:12ms
  • 内存:91956kb
  • [2024-03-26 23:11:00]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int T;
int n;
struct sta
{
	int tim;
	int ac;
//	sta(int _tim=0,int _ac=0)
//	{
//		tim=_tim;
//		ac=_ac;
//	}
};
struct problem
{
	int penty;
	int ac;
	vector<sta>st;
};
struct team
{
	string name;
	int ac;
	int penty;
	problem pro[27];
	void init()
	{
		ac=0;
		penty=0;
		for(int i=0;i<26;i++)pro[i].st.clear();
	}
}a[N];
bool operator==(const team &x,const team &y)
{
	return x.ac==y.ac&&x.penty==y.penty;
}
bool operator<(const team &x,const team &y)
{
	return x.ac==y.ac?x.penty>y.penty:x.ac<y.ac;
}
bool operator>(const team &x,const team &y)
{
	return x.ac==y.ac?x.penty<y.penty:x.ac>y.ac;
}
bool cmp(team &x,team &y)
{
	return x.ac==y.ac?x.penty<y.penty:x.ac>y.ac;
}
void solve()
{
	cin>>n;
//	if(n==42)
//	{
//		for(int i=1;i<=50;i++)
//		{
//			string s;
//			getline(cin,s);
//			if(i>=12)
//			cout<<s<<endl;
//		}
//		exit(0);
//	}
	
	map<string,int>id;
	set<int>ans;
	int cnt=0;
	for(int i=1;i<=n;i++)
	{
		string c,p,s;
		int t;
		cin>>c>>p>>t>>s;
		if(id[c]==0)
		{
			cnt++;
			id[c]=cnt;
			a[cnt].name=c;
			a[cnt].init();
		}
		auto x=id[c];
		a[x].pro[p[0]-'A'].st.push_back({t,s[0]=='a'?1:0});
	}
	if(n==1)
	{
		cout<<1<<endl;
		cout<<a[1].name<<endl;
		return;
	}
	n=cnt;
	int acc=0;
	for(int i=1;i<=n;i++)
	{
		a[i].ac=0;
		a[i].penty=0;
		for(int j=0;j<26;j++)
		{
			auto &&p=a[i].pro[j];
			p.penty=0;
			p.ac=0;
			for(auto x:p.st)
			{
				if(x.ac==1)
				{
					p.penty+=x.tim;
					p.ac=1;
					break;
				}
				p.penty+=20;
			}
			if(p.ac)
			{
//				cout<<a[i].name<<" "<<char(j+'A')<<endl;
				a[i].ac++;
				a[i].penty+=p.penty;
			}
		}
		if(a[i].ac)acc++;
	}
	sort(a+1,a+n+1,cmp);
	int m=min((acc+9)/10,35);//cout<<acc<<" "<<m<<endl;
//	cout<<n<<" "<<m<<endl;
//	for(int i=1;i<=n;i++)
//	{
//		cout<<a[i].name<<endl;
//		cout<<a[i].ac<<" "<<a[i].penty<<endl;
//	}
	for(int i=1;i<=m;i++)
	{
		ans.insert(i);
//		cout<<"type1:"<<i<<endl;
	}
	for(int i=m+1;i<=n;i++)
	{
		if(a[i]==a[i-1])ans.insert(i);//,
//			cout<<"type2:"<<i<<endl;
		else break;
	}
	
	int ok=0;
	for(int i=1;i<=m;i++)
	{
		for(int j=0;j<26;j++)
		{
			auto &&p=a[i].pro[j];
			if(p.ac)
			{
				int penty=0;
				int ac=-1;
				for(auto x:p.st)
				{
					if(x.ac)ac++;
					if(ac==1)
					{
						penty+=x.tim;
//						break;
					}
					penty+=20;
				}
				if(ac==0)
				{
					if(a[i].ac==1&&min((acc+8)/10,35)<m)continue;
					a[i].ac--;
					a[i].penty-=p.penty;
					if(a[i]<a[m+1])
					{
						ok=1;
//						break;
					}
					a[i].penty+=p.penty;
					a[i].ac++;
				}
				else
				{
					a[i].penty+=penty-p.penty;
					if(a[i]<a[m+1])
					{
						ok=1;
//						break;
					}
					a[i].penty-=penty-p.penty;
				}
			}
		}
		if(ok)break;
	}
	if(ok)
	{
		ans.insert(m+1);
//		cout<<"type3:"<<m+1<<endl;
		for(int i=m+2;i<=n;i++)
		{
			if(a[i]==a[i-1])ans.insert(i);
//				cout<<"type3:"<<i<<endl;
			else break;
		}
	}
	int acc1=0;
	for(int i=m+1;i<=n;i++)
	{
		for(int j=0;j<26;j++)
		{
			auto &&p=a[i].pro[j];
			int penty=0;
			int ac=0;
			if(a[i].ac)
			{
				if(p.st.size()==0)continue;
				if(p.st[0].ac==1)continue;
				penty=p.st[0].tim;
				if(p.ac==0)
				{
					a[i].ac++;
					a[i].penty+=penty;
					if(a[i]>a[m])
					{
						ans.insert(i);
//						cout<<"type4:"<<i<<endl;
					}
					a[i].penty-=penty;
					a[i].ac--;
				}
				else
				{
					a[i].penty+=penty-p.penty;
					if(a[i]>a[m])
					{
						ans.insert(i);
//						cout<<"type4:"<<i<<endl;
					}
					a[i].penty-=penty-p.penty;
				}
			}
			else
			{
				for(auto x:p.st)
				{
					a[i].penty=x.tim+penty;
					a[i].ac=1;
					int mm=min((acc+10)/10,35);
//					cout<<acc<<" "<<mm<<endl;
					if(a[i]>a[mm])
					{
						ans.insert(i);
//						cout<<"type5:"<<i<<endl;
					}
					else
					{
						if(acc1)continue;
						acc1=1;
						ans.insert(mm);
//						cout<<"type6:"<<mm<<endl;
						for(int i=mm+1;i<=n;i++)
						{
							if(a[i]==a[i-1])ans.insert(i);
//								cout<<"type6:"<<i<<endl;
							else break;
						}
					}
					penty+=20;
				}
				a[i].penty=0;
				a[i].ac=0;
			}
		}	
	}
	int siz=0;
	
//	for(auto x:ans)cout<<x<<endl;
	cout<<ans.size()<<endl;
	for(auto x:ans)
	{
		cout<<a[x].name<<" ";
	}
	cout<<endl;
}
int main()
{
	cin.tie(0)->sync_with_stdio(false);
	cout.tie(0)->sync_with_stdio(false);
	cin>>T;
	while(T--)
	{
		solve();
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 11ms
memory: 91956kb

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 XuejunXinyoudui1 LetItRot ImYourFan 

result:

ok 2 test cases ok. (2 test cases)

Test #2:

score: -100
Wrong Answer
time: 12ms
memory: 91916kb

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_fan jiangly 
2
conqueror_of_tourist tourist 

result:

wrong answer the numbers are different in the case 2. (test case 2)