QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#55043#2967. Snowball FightSa3tElSefrWA 3ms3708kbC++2.5kb2022-10-12 02:35:192022-10-12 02:35:20

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:35:20]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3708kb
  • [2022-10-12 02:35:19]
  • 提交

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;

void doWork() {

    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 lo = 0, hi = 1000000000000000000;

        while(lo < hi) {
            ll md = lo + (hi-lo+1)/2;
            if(vp[1].F-md >= vp[0].F && vp[2].F-md*2>=vp[1].F-md)
                lo=md;
            else
                hi=md-1;
        }
        vp[1].F -= lo;
        vp[2].F -= lo * 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;
        }
        cout << char((vp[2].S+vp[2].F + 4 - (vp[2].F%3))%3 + 'A') << " 1\n";
    }   else {
        if((vp[1].F-vp[0].F)%3 != 2)
            cout << "Rubble!\n";
        else {
            cout << char((vp[0].F+vp[0].S-'A'+vp[0].F+2)%3+'A') << " 1\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: 3ms
memory: 3492kb

input:

10 3 1

output:

A 3

result:

ok single line: 'A 3'

Test #2:

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

input:

3 2 1

output:

Rubble!

result:

ok single line: 'Rubble!'

Test #3:

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

input:

2 3 2

output:

B 1

result:

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