QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#537335 | #9156. 百万富翁 | shiomusubi496# | 68.99999 | 2133ms | 83496kb | C++17 | 2.4kb | 2024-08-30 10:11:35 | 2024-08-30 10:11:36 |
Judging History
answer
#include "richest.h"
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); --i)
#define all(v) begin(v), end(v)
#define rall(v) rbegin(v), rend(v)
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<class T, class U> bool chmin(T& a, const U& b) { return a > b ? a = b, true : false; }
template<class T, class U> bool chmax(T& a, const U& b) { return a < b ? a = b, true : false; }
constexpr ll inf = 1001001001001001001;
int richest(int N, int T, int S) {
if (T == 1) {
vector<int> a, b;
rep (i, N) rep (j, i) a.push_back(i), b.push_back(j);
auto c = ask(a, b);
vector<bool> used(N);
rep (i, a.size()) used[a[i] ^ b[i] ^ c[i]] = true;
rep (i, N) {
if (!used[i]) return i;
}
return -1;
}
vector<int> A(N); iota(all(A), 0);
while (A.size() > 62500) {
vector<int> X, Y;
rep (i, A.size() / 2) {
X.push_back(A[i * 2]);
Y.push_back(A[i * 2 + 1]);
}
vector<int> B = ask(X, Y);
if (A.size() % 2 == 1) B.push_back(A.back());
A = B;
}
while (A.size() > 300) {
vector<int> X, Y;
rep (i, A.size() / 3) {
rep (k, 3) X.push_back(A[i * 3 + k % 3]);
rep (k, 3) Y.push_back(A[i * 3 + (k + 1) % 3]);
}
if (A.size() % 3 == 2) {
X.push_back(A[A.size() - 2]);
Y.push_back(A[A.size() - 1]);
}
if (A.size() % 3 == 1) A = {A.back()};
else A.clear();
auto B = ask(X, Y);
rep (i, B.size() / 3) {
if (B[i * 3] == B[i * 3 + 1]) A.push_back(B[i * 3]);
else if (B[i * 3 + 1] == B[i * 3 + 2]) A.push_back(B[i * 3 + 1]);
else A.push_back(B[i * 3 + 2]);
}
if (B.size() % 3 == 1) A.push_back(B.back());
}
if (A.size() == 1) return A[0];
vector<int> X, Y;
rep (i, A.size()) rep (j, i) {
X.push_back(A[i]);
Y.push_back(A[j]);
}
auto B = ask(X, Y);
map<int, int> mp;
for (int i : B) ++mp[i];
for (auto [x, v] : mp) {
if (v == A.size() - 1) return x;
}
return -1;
}
Details
Tip: Click on the bar to expand more detailed information
Pretests
Pretest #1:
score: 15
Accepted
time: 643ms
memory: 23096kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 54
Acceptable Answer
time: 2133ms
memory: 83496kb
input:
1000000 20 2000000 29091473
output:
Partially correct Case 2, 54 / 85, maxt = 10, maxs = 1064015 6011678608689133927 0.635294 4439523384460221017
result:
points 0.635294 Partially correct Case 2, 54 / 85, maxt = 10, maxs = 1064015
Final Tests
Test #1:
score: 15
Accepted
time: 615ms
memory: 22892kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 54
Acceptable Answer
time: 2108ms
memory: 83288kb
input:
1000000 20 2000000 29091471
output:
Partially correct Case 2, 54 / 85, maxt = 10, maxs = 1064015 6011678608689133927 0.635294 4439523384460221017
result:
points 0.635294 Partially correct Case 2, 54 / 85, maxt = 10, maxs = 1064015