QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#602214 | #7030. Ultraman vs. Aodzilla and Bodzilla | ucup-team5071# | WA | 72ms | 3744kb | C++20 | 2.4kb | 2024-09-30 21:12:20 | 2024-09-30 21:12:21 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
void Solve(){
int h1,h2,a1,a2;
cin>>h1>>h2>>a1>>a2;
int s=0,m1=0,p1=0,n1=0,m2=0,p2=0,n2=0,pl=0;
while(1){
++m1;
s+=m1;
if(s>=h1){
p1=s-h1;
break;
}
}
n1=m1;
s=p1;
while(1){
++n1;
s+=n1;
if(s>=h2){
if(s-h2>=p1)p1=0;
break;
}
}
s=0;
while(1){
++m2;
s+=m2;
if(s>=h2){
p2=s-h2;
break;
}
}
n2=m2;
s=p2;
while(1){
++n2;
s+=n2;
if(s>=h1){
pl=h1-(s-p2);
break;
}
}
if(a1*m1+a2*n1<a2*m2+a1*n2){
cout<<a1*m1+a2*n1<<" ";
for(int i=1;i<=m1;i++){
if(i==p1)cout<<'B';
else cout<<'A';
}
for(int i=m1+1;i<=n1;i++)
cout<<'B';
}
else if(a1*m1+a2*n1>a2*m2+a1*n2){
cout<<a2*m2+a1*n2<<" ";
int now=0,P=0,maxn=0;s=0;
while(1){
++now;
s+=now;
if(s>p2)
break;
if(pl>s&&pl-s<=now)continue;
maxn=max(maxn,now);
}
P=pl-(1+maxn)*maxn/2;
//cout<<maxn<<" "<<pl<<" "<<p2<<endl;
for(int i=1;i<=m2;i++){
if(i<=maxn||i==P)cout<<'A';
else cout<<'B';
}
for(int i=m2+1;i<=n2;i++)
cout<<'A';
}
else {
cout<<a1*m1+a2*n1<<" ";
string s1,s2;
for(int i=1;i<=m1;i++){
if(i==p1)s1.push_back('B');
else s1.push_back('A');
}
for(int i=m1+1;i<=n1;i++)
s1.push_back('B');
s=0;
int now=0,P=0,maxn=0;s=0;
while(1){
++now;
s+=now;
if(s>p2)
break;
if(pl>s&&pl-s<=now)continue;
maxn=max(maxn,now);
}
//cout<<maxn<<" "<<pl<<" "<<p2<<endl;
for(int i=1;i<=m2;i++){
if(i<=maxn||i==P)s2.push_back('A');
else s2.push_back('B');
}
for(int i=m2+1;i<=n2;i++)
s2.push_back('A');
cout<<min(s1,s2);
}
cout<<'\n';
}
signed main(){
ios::sync_with_stdio(false),cin.tie(0);
int T;
cin>>T;
while(T--)Solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3560kb
input:
2 5 15 5 25 5 15 25 5
output:
155 BBBBBA 105 AAABBB
result:
ok 2 cases
Test #2:
score: -100
Wrong Answer
time: 72ms
memory: 3744kb
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:
wrong answer In case 99957, the monster A is still alive.