QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#55039#2967. Snowball FightSa3tElSefrWA 2ms3724kbC++3.4kb2022-10-12 02:20:492022-10-12 02:20:50

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-12 02:20:50]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3724kb
  • [2022-10-12 02:20:49]
  • 提交

answer

/// tban lecodes el bosta2
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;


#define pb push_back
#define F first
#define S second
#define f(i, a, b)  for(int i = a; i < b; i++)
#define all(a)  a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) (int)(x).size()
#define mp(x,y) make_pair(x,y)
#define popCnt(x) (__builtin_popcountll(x))
#define int ll

using ll = long long;
using ii = pair<int, int>;
using ull = unsigned long long;
const int N = 2e5+5, LG = 18, MOD = 1e9+7;
const long double PI = acos(-1);
const long double EPS = 1e-7;
bool vis[105][105][105];
pair<char, int> dp[105][105][105];
pair<char, int> solve(int x, int y, int z) {
    ///ABC
    if(!x + !y + !z >= 2) {
        if(x)return make_pair('A', x);
        if(y)return make_pair('B', y);
        if(z)return make_pair('C', z);
        return make_pair('D', 0);
    }
    if(vis[x][y][z])
        return dp[x][y][z];
    vis[x][y][z] = true;
    array<int, 3> sub; sub[0] = sub[1] = sub[2] = 0;
    if(x) {
        if(y >= z)sub[1] += 1;
        else sub[2] += 1;
    }
    if(y) {
        if(z >= x)sub[2] += 1;
        else sub[0] += 1;
    }
    if(z) {
        if(x >= y)sub[0] += 1;
        else sub[1] += 1;
    }
    return dp[x][y][z] = solve(x - sub[0], y - sub[1], z - sub[2]);
}
void doWork() {

//    f(i,1,6)
//    f(j,1,6)
//    f(k,1,6) {
//        if(max({i,j,k})-min({i,j,k})!=1)continue;
//        if(min({i,j,k}) != i+j+k-min({i,j,k})-max({i,j,k}))continue;
//        cout << i << ' ' << j << ' ' << k << '\n';
//        auto ans = solve(i,j,k);
//        cout << ans.F << ' ' << ans.S << '\n';
//    }

    ll A, B, C;
    cin >> A >> B >> C;
    vector<pair<ll, char>> vp({{A,'A'}, {B,'B'}, {C,'C'}});

    sort(all(vp));
    ///first iteration
    {
        ll x = min(vp[1].F - vp[0].F, (vp[2].F - vp[1].F) / 2);
        vp[1].F -= x;
        vp[2].F -= x * 2;

    }


    if(vp[0].F == vp[1].F) {
        ll lo = 0, hi = min(vp[1].F - 1, vp[2].F / 2);
        while(lo < hi) {
            ll md = lo + (hi-lo+1)/2;
            if(vp[1].F - md <= vp[2].F - md * 4)
                lo = md;
            else
                hi = md - 1;
        }
        vp[0].F -= lo;
        vp[1].F -= lo;
        vp[2].F -= lo * 4;

        if(vp[0].F == 1 && vp[2].F > 3) {
            vp[2].F -= 3;
            vp[0].F -= 1;
            vp[1].F -= 1;
        }

        if(vp[0].F == 0) {
            cout << vp.back().S << ' ' << vp.back().F << '\n';
            return;
        }
        ///vp[0]+2 >= vp[2]
        if(vp[0].F == vp[2].F || vp[0].F + 2 == vp[2].F) {
            cout << "Rubble!\n";
            return;
        }

        if(vp[2].F % 3 == 2) {
            cout << char((vp[2].S+vp[2].F + 1)%3 + 'A') << " 1\n";
        } else if(vp[2].F % 3 == 1) {
            cout << char((vp[2].S+vp[2].F)%3 + 'A') << " 1\n";
        }   else {
            cout << char((vp[2].S+vp[2].F + 2)%3 + 'A') << " 1\n";
        }

    }   else {
        cout << "Rubble!\n";
    }



}
int32_t main() {
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif // ONLINE_JUDGE

    int t = 1;
//    cin >> t;
    while (t--) {
        doWork();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

10 3 1

output:

A 3

result:

ok single line: 'A 3'

Test #2:

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

input:

3 2 1

output:

Rubble!

result:

ok single line: 'Rubble!'

Test #3:

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

input:

2 3 2

output:

C 1

result:

ok single line: 'C 1'

Test #4:

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

input:

100 101 100

output:

A 1

result:

ok single line: 'A 1'

Test #5:

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

input:

100 99 100

output:

Rubble!

result:

ok single line: 'Rubble!'

Test #6:

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

input:

1000 5000 1000

output:

B 1001

result:

ok single line: 'B 1001'

Test #7:

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

input:

2000 1000 1000

output:

C 1

result:

ok single line: 'C 1'

Test #8:

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

input:

1000000000000000 2000000000000000 4000000000000000

output:

B 1

result:

ok single line: 'B 1'

Test #9:

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

input:

1000000000000000 2000000000000000 4000000000000001

output:

Rubble!

result:

ok single line: 'Rubble!'

Test #10:

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

input:

1 1 1

output:

Rubble!

result:

ok single line: 'Rubble!'

Test #11:

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

input:

1000000000000000000 1000000000000000000 1000000000000000000

output:

Rubble!

result:

ok single line: 'Rubble!'

Test #12:

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

input:

1000000000000000000 1000000000000000000 999999999999999999

output:

Rubble!

result:

ok single line: 'Rubble!'

Test #13:

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

input:

999999999999999999 999999999999999999 1000000000000000000

output:

C 1

result:

ok single line: 'C 1'

Test #14:

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

input:

1000000000000000000 666666666666666666 333333333333333343

output:

Rubble!

result:

ok single line: 'Rubble!'

Test #15:

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

input:

1000000000000000000 1000000000000000000 1

output:

Rubble!

result:

ok single line: 'Rubble!'

Test #16:

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

input:

1000000000000000000 1 1000000000000000000

output:

Rubble!

result:

ok single line: 'Rubble!'

Test #17:

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

input:

1 1000000000000000000 1000000000000000000

output:

Rubble!

result:

ok single line: 'Rubble!'

Test #18:

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

input:

1 1 1000000000000000000

output:

C 999999999999999997

result:

ok single line: 'C 999999999999999997'

Test #19:

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

input:

1 1000000000000000000 1

output:

B 999999999999999997

result:

ok single line: 'B 999999999999999997'

Test #20:

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

input:

1000000000000000000 1 1

output:

A 999999999999999997

result:

ok single line: 'A 999999999999999997'

Test #21:

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

input:

1 1 2

output:

B 1

result:

ok single line: 'B 1'

Test #22:

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

input:

1 2 1

output:

A 1

result:

ok single line: 'A 1'

Test #23:

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

input:

2 1 1

output:

C 1

result:

ok single line: 'C 1'

Test #24:

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

input:

444157599796692942 46675314082485334 560236489768887907

output:

Rubble!

result:

ok single line: 'Rubble!'

Test #25:

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

input:

956755259049838138 412802820832641541 251847321245586964

output:

Rubble!

result:

ok single line: 'Rubble!'

Test #26:

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

input:

160571653790836855 161115915384424052 109332424445158010

output:

Rubble!

result:

ok single line: 'Rubble!'

Test #27:

score: -100
Wrong Answer
time: 2ms
memory: 3644kb

input:

921648419000118845 614004066072469867 813008253605106742

output:

Rubble!

result:

wrong answer 1st lines differ - expected: 'C 1', found: 'Rubble!'