QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#654864 | #7030. Ultraman vs. Aodzilla and Bodzilla | welikestudying | RE | 0ms | 0kb | C++14 | 1005b | 2024-10-18 22:37:48 | 2024-10-18 22:37:50 |
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];
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;
}
assert(S<=max(uu[0],0)+max(uu[1],0));
rs[p]=1ll*n*atk[p]+1ll*m*atk[p^1];
up(i,1,n)
{
if(uu[1]-S+i<=0)
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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Runtime Error
input:
2 5 15 5 25 5 15 25 5