QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#537294#9156. 百万富翁Forested#51.99999 2161ms99752kbC++173.2kb2024-08-30 09:20:482024-08-30 09:20:48

Judging History

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

  • [2024-08-30 09:20:48]
  • 评测
  • 测评结果:51.99999
  • 用时:2161ms
  • 内存:99752kb
  • [2024-08-30 09:20:48]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

using i32 = int;
using i64 = long long;
template <typename T>
using V = vector<T>;
template <typename T>
using VV = V<V<T>>;
template <typename T>
using VVV = V<V<V<T>>>;

template <typename T>
bool chmin(T &x, const T &y) {
    if (x > y) {
        x = y;
        return true;
    }
    return false;
}
template <typename T>
bool chmax(T &x, const T &y) {
    if (x < y) {
        x = y;
        return true;
    }
    return false;
}

#define OVERRIDE4(a, b, c, d, ...) d
#define REP2(i, n) for (i32 i = 0; i < (i32)(n); ++i)
#define REP3(i, l, r) for (i32 i = (i32)(l); i < (i32)(r); ++i)
#define REP(...) OVERRIDE4(__VA_ARGS__, REP3, REP2)(__VA_ARGS__)
#define PER2(i, n) for (i32 i = (i32)(n)-1; i >= 0; --i)
#define PER3(i, l, r) for (i32 i = (i32)(r)-1; i >= (i32)(l); --i)
#define PER(...) OVERRIDE4(__VA_ARGS__, PER3, PER2)(__VA_ARGS__)
#define ALL(x) begin(x), end(x)
#define LEN(x) (i32) size(x)

void dbg(i32 x) { cerr << x; }
void dbg(i64 x) { cerr << x; }
template <typename T>
void dbg(V<T> arr) {
    cerr << '[';
    REP(i, LEN(arr)) {
        if (i) {
            cerr << ", ";
        }
        dbg(arr[i]);
    }
    cerr << ']';
}
void debug() { cerr << "\n"; }
template <typename Head, typename... Tail>
void debug(Head head, Tail... tail) {
    dbg(head);
    cerr << ", ";
    debug(tail...);
}

#ifdef DEBUGF
#define DBG(...)                       \
    do {                               \
        cerr << #__VA_ARGS__ << " : "; \
        debug(__VA_ARGS__);            \
    } while (false)
#else
#define DBG(...) (void)0
#endif

#include "richest.h"

i32 richest(i32 n, i32 t, i32 s) {
    if (t == 1) {
        V<i32> a, b;
        REP(i, n) REP(j, i + 1, n) {
            a.push_back(i);
            b.push_back(j);
        }
        V<i32> c = ask(a, b);
        VV<i32> gr(n, V<i32>(n, 1));
        REP(i, LEN(c)) {
            if (c[i] == a[i]) {
                gr[b[i]][a[i]] = 0;
            } else {
                gr[a[i]][b[i]] = 0;
            }
        }
        i32 ans = -1;
        REP(i, n) {
            if (count(ALL(gr[i]), 1) == n) {
                ans = i;
            }
        }
        return ans;
    }
    
    s = 1099944;
    V<i32> rem(n);
    iota(ALL(rem), 0);
    while (LEN(rem) > 1) {
        if ((i64)LEN(rem) * (LEN(rem) - 1) / 2 <= s) {
            V<i32> a, b;
            REP(i, LEN(rem)) REP(j, i + 1, LEN(rem)) {
                a.push_back(rem[i]);
                b.push_back(rem[j]);
            }
            V<i32> c = ask(a, b);
            i32 ans = -1;
            for (i32 ele : rem) {
                if (count(ALL(c), ele) == LEN(rem) - 1) {
                    ans = ele;
                }
            }
            rem.clear();
            rem.push_back(ans);
            break;
        }
        V<i32> a, b;
        REP(i, LEN(rem) / 2) {
            a.push_back(rem[2 * i]);
            b.push_back(rem[2 * i + 1]);
        }
        V<i32> c = ask(a, b);
        if (LEN(rem) % 2) {
            c.push_back(rem.back());
        }
        rem.swap(c);
        s -= LEN(a);
    }
    return rem[0];
}

Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 15
Accepted
time: 639ms
memory: 23540kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 37
Acceptable Answer
time: 2116ms
memory: 99752kb

input:

1000000 20 2000000 29091473

output:

Partially correct Case 2, 37 / 85, maxt = 13, maxs = 1029645
14233204743512706019
0.435294
13281437197936769557

result:

points 0.435294 Partially correct Case 2, 37 / 85, maxt = 13, maxs = 1029645


Final Tests

Test #1:

score: 15
Accepted
time: 631ms
memory: 24072kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 37
Acceptable Answer
time: 2161ms
memory: 95768kb

input:

1000000 20 2000000 29091471

output:

Partially correct Case 2, 37 / 85, maxt = 13, maxs = 1029645
14233204743512706019
0.435294
13281437197936769557

result:

points 0.435294 Partially correct Case 2, 37 / 85, maxt = 13, maxs = 1029645