QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#654929#7030. Ultraman vs. Aodzilla and BodzillawelikestudyingAC ✓185ms3656kbC++141.1kb2024-10-18 22:56:442024-10-18 22:56:44

Judging History

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

  • [2024-10-18 22:56:44]
  • 评测
  • 测评结果:AC
  • 用时:185ms
  • 内存:3656kb
  • [2024-10-18 22:56:44]
  • 提交

answer

#include<bits/stdc++.h>
const int N=114514;
#define up(a,b,c)for(int a=b;a<=c;++a)
#define dn(a,b,c)for(int a=b;a>=c;--a)
using namespace std;
int T,S,m,n,hp[2],atk[2];
long long rs[2];
bool cc[2][N];
int mxc(int i,int n,int S,int u)
{
	if(u<=0)return 0;
	if(u<=i)return i;
	return u;
}
void clc(bool p)
{
	S=0;
	int V=hp[p];
	up(i,1,m)S+=i;
	fill(cc[p],cc[p]+m+1,p^1);
	int uu[2]={hp[0],hp[1]};
	dn(i,m,1)
	{
		if(S-i<V)
		{
			n=i;
			break;
		}
		S-=i,uu[p^1]-=i;
	}
	rs[p]=1ll*n*atk[p]+1ll*m*atk[p^1];
	up(i,1,n)
	{
		if(mxc(i+1,n,S-i,uu[0]-i)+mxc(i+1,n,S-i,uu[1])<=S-i)
			cc[p][i]=0,S-=i,uu[0]-=i;
		else cc[p][i]=1,S-=i,uu[1]-=i;
	}
}
bool cmp()
{
	if(rs[0]!=rs[1])return rs[1]<rs[0];
	up(i,1,m)
		if(cc[0][i]!=cc[1][i])return cc[1][i]<cc[0][i];
	return 0;
}
int main()
{
	cin>>T;
	while(T--)
	{
		cin>>hp[0]>>hp[1]>>atk[0]>>atk[1];
		S=0;
		for(m=1;;++m)
			if(S+m>=hp[0]+hp[1])break;
			else S+=m;
		clc(0),clc(1);
		bool p=cmp();
		cout<<rs[p]<<' ';
		up(i,1,m)
			cout<<(cc[p][i]?'B':'A');
		cout<<'\n';
	}
	return 0;
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3652kb

input:

2
5 15 5 25
5 15 25 5

output:

155 BBBBBA
105 AAABBB

result:

ok 2 cases

Test #2:

score: 0
Accepted
time: 185ms
memory: 3656kb

input:

100000
1 1 1 1
1 1 1 2
1 1 1 3
1 1 1 4
1 1 1 5
1 1 1 6
1 1 1 7
1 1 1 8
1 1 1 9
1 1 1 10
1 1 2 1
1 1 2 2
1 1 2 3
1 1 2 4
1 1 2 5
1 1 2 6
1 1 2 7
1 1 2 8
1 1 2 9
1 1 2 10
1 1 3 1
1 1 3 2
1 1 3 3
1 1 3 4
1 1 3 5
1 1 3 6
1 1 3 7
1 1 3 8
1 1 3 9
1 1 3 10
1 1 4 1
1 1 4 2
1 1 4 3
1 1 4 4
1 1 4 5
1 1 4 6
1 ...

output:

3 AB
4 BA
5 BA
6 BA
7 BA
8 BA
9 BA
10 BA
11 BA
12 BA
4 AB
6 AB
7 BA
8 BA
9 BA
10 BA
11 BA
12 BA
13 BA
14 BA
5 AB
7 AB
9 AB
10 BA
11 BA
12 BA
13 BA
14 BA
15 BA
16 BA
6 AB
8 AB
10 AB
12 AB
13 BA
14 BA
15 BA
16 BA
17 BA
18 BA
7 AB
9 AB
11 AB
13 AB
15 AB
16 BA
17 BA
18 BA
19 BA
20 BA
8 AB
10 AB
12 AB
14...

result:

ok 100000 cases