QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#55479#2967. Snowball FightMahmoudAtia#AC ✓2ms3744kbC++2.7kb2022-10-14 00:15:332022-10-14 00:15:34

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-14 00:15:34]
  • 评测
  • 测评结果:AC
  • 用时:2ms
  • 内存:3744kb
  • [2022-10-14 00:15:33]
  • 提交

answer

#include <bits/stdc++.h>

typedef long double ld;
typedef long long ll;
using namespace std;
int di[] = {1, 0, -1, -1, 0, 1, -1, 1};
int dj[] = {1, 1, 0, -1, -1, 0, 1, -1};
const ll oo = 1e18, MOD = 998244353;
const int N = 3e5 + 5, M = 105;
const ld PI = acos(-1.0), EPS = 1e-9;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ll a, b, c, nxt[3], idx[3];
pair<ll, ll> p[3];
string s = "ABC";

bool ok(ll mid) {
    a = p[0].first, b = p[1].first - mid, c = p[2].first - mid * 2;
    if (b < a || c < b) return 0;
    return 1;
}

bool ok2(ll mid) {
    ll r[3];
    r[0] = p[0].first - mid / 2, r[1] = p[1].first - mid / 2, r[2] = p[2].first - mid * 2;
    if (!r[0]) r[2]++;
    if (mid & 1) r[idx[nxt[p[2].second]]]--;
    if (r[2] < max(r[0], r[1]) || min({r[0], r[1], r[2]}) < 0) return 0;
    return 1;
}

//#define endl '\n'
int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //freopen("farm.in", "r", stdin);
    //memset(dp, -1, sizeof dp);
    for (int i = 0; i < 3; i++) cin >> p[i].first, p[i].second = i, nxt[i] = i + 1;
    nxt[2] = 0;
    sort(p, p + 3);
    for (int i = 0; i < 3; i++) idx[p[i].second] = i;
    ll l = 1, r = oo, mid, ans = 0;
    while (l <= r) {
        mid = (l + r) >> 1;
        if (ok(mid)) ans = mid, l = mid + 1;
        else r = mid - 1;
    }
    p[1].first -= ans, p[2].first -= ans * 2;
    //cout << p[0].first << " " << p[1].first << " " << p[2].first << endl;
    if (p[1].first == p[2].first) {
        ll num = (p[1].first - p[0].first) / 3;
        p[1].first -= num * 3;
        p[2].first -= num * 3;
        if (p[1].first - p[0].first == 2) {
            p[1].first--, p[2].first--;
            p[idx[nxt[p[0].second]]].first--;
        }
    } else if (p[1].first == p[0].first) {
        ll l = 1, r = oo, mid, ans = 0;
        while (l <= r) {
            mid = (l + r) >> 1;
            if (ok2(mid)) ans = mid, l = mid + 1;
            else r = mid - 1;
        }
        //cout << ans << endl;
        p[0].first -= ans / 2, p[1].first -= ans / 2, p[2].first -= ans * 2;
        if (!p[0].first) p[2].first++;
        if (ans & 1) p[idx[nxt[p[2].second]]].first--;
    }
    sort(p, p + 3);
    //for (int i = 0; i < 3; i++) cout << p[i].first << " " << p[i].second << endl;
    //cout << endl;
    if (p[1].first == p[2].first) cout << "Rubble!";
    else if (p[1].first == 0) cout << s[p[2].second] << " " << p[2].first;
    else cout << s[(p[2].second - p[2].first + 1 + oo * 3) % 3] << " " << 1;
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3632kb

input:

10 3 1

output:

A 3

result:

ok single line: 'A 3'

Test #2:

score: 0
Accepted
time: 2ms
memory: 3744kb

input:

3 2 1

output:

Rubble!

result:

ok single line: 'Rubble!'

Test #3:

score: 0
Accepted
time: 2ms
memory: 3604kb

input:

2 3 2

output:

C 1

result:

ok single line: 'C 1'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3632kb

input:

100 101 100

output:

A 1

result:

ok single line: 'A 1'

Test #5:

score: 0
Accepted
time: 2ms
memory: 3668kb

input:

100 99 100

output:

Rubble!

result:

ok single line: 'Rubble!'

Test #6:

score: 0
Accepted
time: 2ms
memory: 3560kb

input:

1000 5000 1000

output:

B 1001

result:

ok single line: 'B 1001'

Test #7:

score: 0
Accepted
time: 2ms
memory: 3700kb

input:

2000 1000 1000

output:

C 1

result:

ok single line: 'C 1'

Test #8:

score: 0
Accepted
time: 2ms
memory: 3636kb

input:

1000000000000000 2000000000000000 4000000000000000

output:

B 1

result:

ok single line: 'B 1'

Test #9:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

1000000000000000 2000000000000000 4000000000000001

output:

Rubble!

result:

ok single line: 'Rubble!'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

1 1 1

output:

Rubble!

result:

ok single line: 'Rubble!'

Test #11:

score: 0
Accepted
time: 2ms
memory: 3528kb

input:

1000000000000000000 1000000000000000000 1000000000000000000

output:

Rubble!

result:

ok single line: 'Rubble!'

Test #12:

score: 0
Accepted
time: 0ms
memory: 3744kb

input:

1000000000000000000 1000000000000000000 999999999999999999

output:

Rubble!

result:

ok single line: 'Rubble!'

Test #13:

score: 0
Accepted
time: 2ms
memory: 3580kb

input:

999999999999999999 999999999999999999 1000000000000000000

output:

C 1

result:

ok single line: 'C 1'

Test #14:

score: 0
Accepted
time: 2ms
memory: 3560kb

input:

1000000000000000000 666666666666666666 333333333333333343

output:

Rubble!

result:

ok single line: 'Rubble!'

Test #15:

score: 0
Accepted
time: 1ms
memory: 3580kb

input:

1000000000000000000 1000000000000000000 1

output:

Rubble!

result:

ok single line: 'Rubble!'

Test #16:

score: 0
Accepted
time: 2ms
memory: 3580kb

input:

1000000000000000000 1 1000000000000000000

output:

Rubble!

result:

ok single line: 'Rubble!'

Test #17:

score: 0
Accepted
time: 2ms
memory: 3524kb

input:

1 1000000000000000000 1000000000000000000

output:

Rubble!

result:

ok single line: 'Rubble!'

Test #18:

score: 0
Accepted
time: 2ms
memory: 3528kb

input:

1 1 1000000000000000000

output:

C 999999999999999997

result:

ok single line: 'C 999999999999999997'

Test #19:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

1 1000000000000000000 1

output:

B 999999999999999997

result:

ok single line: 'B 999999999999999997'

Test #20:

score: 0
Accepted
time: 2ms
memory: 3528kb

input:

1000000000000000000 1 1

output:

A 999999999999999997

result:

ok single line: 'A 999999999999999997'

Test #21:

score: 0
Accepted
time: 2ms
memory: 3668kb

input:

1 1 2

output:

B 1

result:

ok single line: 'B 1'

Test #22:

score: 0
Accepted
time: 2ms
memory: 3636kb

input:

1 2 1

output:

A 1

result:

ok single line: 'A 1'

Test #23:

score: 0
Accepted
time: 2ms
memory: 3636kb

input:

2 1 1

output:

C 1

result:

ok single line: 'C 1'

Test #24:

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

input:

444157599796692942 46675314082485334 560236489768887907

output:

Rubble!

result:

ok single line: 'Rubble!'

Test #25:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

956755259049838138 412802820832641541 251847321245586964

output:

Rubble!

result:

ok single line: 'Rubble!'

Test #26:

score: 0
Accepted
time: 2ms
memory: 3524kb

input:

160571653790836855 161115915384424052 109332424445158010

output:

Rubble!

result:

ok single line: 'Rubble!'

Test #27:

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

input:

921648419000118845 614004066072469867 813008253605106742

output:

C 1

result:

ok single line: 'C 1'

Test #28:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

693945840953877919 169434960463419660 113866378987295962

output:

A 127343162052446676

result:

ok single line: 'A 127343162052446676'

Test #29:

score: 0
Accepted
time: 2ms
memory: 3584kb

input:

85019237241209084 980529565679633437 380691477259981355

output:

B 49108136677252560

result:

ok single line: 'B 49108136677252560'

Test #30:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

645421234567141464 407893628649180661 364549975476396707

output:

Rubble!

result:

ok single line: 'Rubble!'

Test #31:

score: 0
Accepted
time: 2ms
memory: 3460kb

input:

738357910767343290 235746790249011133 637016428074206146

output:

Rubble!

result:

ok single line: 'Rubble!'

Test #32:

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

input:

510390692617211911 601079822093185951 71803470531764164

output:

Rubble!

result:

ok single line: 'Rubble!'

Test #33:

score: 0
Accepted
time: 2ms
memory: 3596kb

input:

107535136359726249 968559233358270701 818866444754832562

output:

Rubble!

result:

ok single line: 'Rubble!'

Test #34:

score: 0
Accepted
time: 2ms
memory: 3532kb

input:

905098446311590477 720882423525283458 705469307748541766

output:

Rubble!

result:

ok single line: 'Rubble!'

Test #35:

score: 0
Accepted
time: 2ms
memory: 3596kb

input:

954691959809318528 384078665351903019 841953877580378475

output:

Rubble!

result:

ok single line: 'Rubble!'

Test #36:

score: 0
Accepted
time: 1ms
memory: 3576kb

input:

811244616949995467 72615926345184233 255607189988205136

output:

A 154798384283216730

result:

ok single line: 'A 154798384283216730'

Test #37:

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

input:

926193781258448632 164284852574664659 626024798607977342

output:

Rubble!

result:

ok single line: 'Rubble!'

Test #38:

score: 0
Accepted
time: 2ms
memory: 3528kb

input:

105164835967083077 564109255000339084 347544484863227666

output:

Rubble!

result:

ok single line: 'Rubble!'

Test #39:

score: 0
Accepted
time: 2ms
memory: 3608kb

input:

335604692427987384 143896955232269694 383635221488408171

output:

Rubble!

result:

ok single line: 'Rubble!'

Test #40:

score: 0
Accepted
time: 2ms
memory: 3672kb

input:

234275783824115394 921676707138510707 630913355295121299

output:

Rubble!

result:

ok single line: 'Rubble!'

Test #41:

score: 0
Accepted
time: 2ms
memory: 3612kb

input:

331646244565684856 105644609571048710 919956442308821358

output:

C 45374734035354227

result:

ok single line: 'C 45374734035354227'

Test #42:

score: 0
Accepted
time: 2ms
memory: 3592kb

input:

365530129751400870 279130545514732915 211986208154388685

output:

Rubble!

result:

ok single line: 'Rubble!'

Test #43:

score: 0
Accepted
time: 2ms
memory: 3740kb

input:

947087216394105639 38014606015037878 299824398374458488

output:

A 271409207615112908

result:

ok single line: 'A 271409207615112908'