QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#537396 | #9156. 百万富翁 | Forested# | 77.99996 | 1959ms | 84816kb | C++17 | 3.2kb | 2024-08-30 12:18:28 | 2024-08-30 12:18:28 |
Judging History
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;
}
V<i32> div({2, 2, 2, 2, 2, 3, 5, 15, 140});
V<i32> rem(n);
iota(ALL(rem), 0);
for (i32 d : div) {
i32 g = LEN(rem) / d;
i32 p = d * (d - 1) / 2;
DBG(LEN(rem), g, p);
V<i32> a, b;
REP(i, g) {
i32 l = d * i, r = d * (i + 1);
REP(j, l, r) REP(k, j + 1, r) {
a.push_back(rem[j]);
b.push_back(rem[k]);
}
}
V<i32> c = ask(a, b);
V<i32> nr;
REP(i, g) {
i32 l = p * i, r = p * (i + 1);
REP(j, d * i, d * (i + 1)) {
i32 win = count(begin(c) + l, begin(c) + r, rem[j]);
if (win == d - 1) {
nr.push_back(rem[j]);
}
}
}
REP(i, d * g, LEN(rem)) {
nr.push_back(rem[i]);
}
rem = nr;
}
return rem[0];
}
Details
Tip: Click on the bar to expand more detailed information
Pretests
Pretest #1:
score: 15
Accepted
time: 618ms
memory: 23600kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 63
Acceptable Answer
time: 1959ms
memory: 84692kb
input:
1000000 20 2000000 29091473
output:
Partially correct Case 2, 63 / 85, maxt = 9, maxs = 1045153 11084197289515765723 0.741176 16601290867448354019
result:
points 0.741176 Partially correct Case 2, 63 / 85, maxt = 9, maxs = 1045153
Final Tests
Test #1:
score: 15
Accepted
time: 593ms
memory: 24148kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 63
Acceptable Answer
time: 1949ms
memory: 84816kb
input:
1000000 20 2000000 29091471
output:
Partially correct Case 2, 63 / 85, maxt = 9, maxs = 1045153 11084197289515765723 0.741176 16601290867448354019
result:
points 0.741176 Partially correct Case 2, 63 / 85, maxt = 9, maxs = 1045153