QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#212614 | #2967. Snowball Fight | ucup-team1004 | TL | 1ms | 3588kb | C++14 | 1.5kb | 2023-10-13 18:15:51 | 2023-10-13 18:15:53 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<typename T>
ostream& operator << (ostream &out,const vector<T>&x){
if(x.empty())return out<<"[]";
out<<'['<<x[0];
for(int len=x.size(),i=1;i<len;i++)out<<','<<x[i];
return out<<']';
}
template<typename T>
vector<T> ary(const T *a,int l,int r){
return vector<T>{a+l,a+1+r};
}
template<typename T>
void debug(T x){
cerr<<x<<'\n';
}
template<typename T,typename ...S>
void debug(T x,S ...y){
cerr<<x<<' ',debug(y...);
}
ll a,b,c;
char A='A',B='B',C='C';
void print(ll x,char y='D'){
if(x==-1)cout<<"Rubble!";
else cout<<y<<' '<<x;
cout<<endl,exit(0);
}
bool flag;
void swp(){
ll mn=min({a,b,c});
if(mn==a);
else if(mn==b){
swap(b,a),swap(B,A);
swap(b,c),swap(B,C);
}else{
swap(b,c),swap(B,C);
swap(a,b),swap(A,B);
}
if(b>c)swap(b,c),swap(B,C),flag=1;
}
int main(){
cin>>a>>b>>c;
swp();
ll t=min(b-a,c-b);
b-=t,c-=t*2;
if(a==b&&b==c)print(-1);
if(a==b){
t=min(a-1,(c-a-1)/3);
a-=t,b-=t,c-=t*4;
}else{
t=(b-a-1)/3;
b-=t*3,c-=t*3;
}
// debug(a,b,c,A,B,C,flag);
for(;a&&b&&c;){
swp();
if((a==b&&b+1==c)||(a+1==b&&b==c)){
ll t=min({a/3-1,b/3-1,c/3-1});
if(t>0)a-=t*3,b-=t*3,c-=t*3;
// debug(a,b,c,A,B,C,flag);
}
int da=0,db=0,dc=0;
if(b>=c+flag)db++;
else dc++;
if(c>=a+flag)dc++;
else da++;
if(a>=b+flag)da++;
else db++;
a-=da,b-=db,c-=dc;
// debug(a,b,c,A,B,C,flag);
}
swp();
if(b==c)print(-1);
else if(b<c)print(c-b,C);
else print(b-c,B);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3432kb
input:
10 3 1
output:
A 3
result:
ok single line: 'A 3'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3424kb
input:
3 2 1
output:
Rubble!
result:
ok single line: 'Rubble!'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
2 3 2
output:
C 1
result:
ok single line: 'C 1'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3476kb
input:
100 101 100
output:
A 1
result:
ok single line: 'A 1'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
100 99 100
output:
Rubble!
result:
ok single line: 'Rubble!'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
1000 5000 1000
output:
B 1001
result:
ok single line: 'B 1001'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3428kb
input:
2000 1000 1000
output:
C 1
result:
ok single line: 'C 1'
Test #8:
score: 0
Accepted
time: 1ms
memory: 3392kb
input:
1000000000000000 2000000000000000 4000000000000000
output:
B 1
result:
ok single line: 'B 1'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3428kb
input:
1000000000000000 2000000000000000 4000000000000001
output:
Rubble!
result:
ok single line: 'Rubble!'
Test #10:
score: 0
Accepted
time: 1ms
memory: 3540kb
input:
1 1 1
output:
Rubble!
result:
ok single line: 'Rubble!'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3428kb
input:
1000000000000000000 1000000000000000000 1000000000000000000
output:
Rubble!
result:
ok single line: 'Rubble!'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3380kb
input:
1000000000000000000 1000000000000000000 999999999999999999
output:
Rubble!
result:
ok single line: 'Rubble!'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3420kb
input:
999999999999999999 999999999999999999 1000000000000000000
output:
C 1
result:
ok single line: 'C 1'
Test #14:
score: 0
Accepted
time: 1ms
memory: 3384kb
input:
1000000000000000000 666666666666666666 333333333333333343
output:
Rubble!
result:
ok single line: 'Rubble!'
Test #15:
score: 0
Accepted
time: 0ms
memory: 3480kb
input:
1000000000000000000 1000000000000000000 1
output:
Rubble!
result:
ok single line: 'Rubble!'
Test #16:
score: 0
Accepted
time: 1ms
memory: 3384kb
input:
1000000000000000000 1 1000000000000000000
output:
Rubble!
result:
ok single line: 'Rubble!'
Test #17:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
1 1000000000000000000 1000000000000000000
output:
Rubble!
result:
ok single line: 'Rubble!'
Test #18:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
1 1 1000000000000000000
output:
C 999999999999999997
result:
ok single line: 'C 999999999999999997'
Test #19:
score: 0
Accepted
time: 0ms
memory: 3476kb
input:
1 1000000000000000000 1
output:
B 999999999999999997
result:
ok single line: 'B 999999999999999997'
Test #20:
score: 0
Accepted
time: 0ms
memory: 3384kb
input:
1000000000000000000 1 1
output:
A 999999999999999997
result:
ok single line: 'A 999999999999999997'
Test #21:
score: 0
Accepted
time: 0ms
memory: 3476kb
input:
1 1 2
output:
B 1
result:
ok single line: 'B 1'
Test #22:
score: 0
Accepted
time: 0ms
memory: 3428kb
input:
1 2 1
output:
A 1
result:
ok single line: 'A 1'
Test #23:
score: 0
Accepted
time: 0ms
memory: 3352kb
input:
2 1 1
output:
C 1
result:
ok single line: 'C 1'
Test #24:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
444157599796692942 46675314082485334 560236489768887907
output:
Rubble!
result:
ok single line: 'Rubble!'
Test #25:
score: -100
Time Limit Exceeded
input:
956755259049838138 412802820832641541 251847321245586964