QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#509966 | #9156. 百万富翁 | Franuch# | 15 | 622ms | 22988kb | C++17 | 1.5kb | 2024-08-08 20:13:47 | 2024-08-08 20:13:48 |
Judging History
answer
#include "richest.h"
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
ll on2(ll n) {
vector<ll> a, b;
for (ll i = 1; i < n; i++) {
for (ll j = 0; j < i; j++) {
a.push_back(i);
b.push_back(j);
}
}
vector<ll> c = ask(a, b);
std::reverse(c.begin(), c.end());
vector<vector<bool>> cmp(n, vector<bool>(n, true));
for (ll i = 1; i < n; i++)
for (ll j = 0; j < i; j++) {
cmp[i][j] = c.back() == i;
cmp[j][i] = c.back() == j;
c.pop_back();
}
for (ll i = 0; i < n; i++) {
bool good = true;
for (ll j = 0; j < n; j++)
good = good and cmp[i][j];
if (good)
return i;
}
return 0;
}
ll onlogn(ll n) {
mt19937 rng(3498);
vector<ll> p(n);
std::iota(p.begin(), p.end(), 0);
while (p.size() > 1) {
std::shuffle(p.begin(), p.end(), rng);
ll P = (ll)p.size();
vector<ll> a, b;
for (ll i = 0; i < P; i++) {
a.push_back(p[i]);
b.push_back(p[(i + 1) % P]);
}
a = ask(a, b);
p.clear();
for (ll i = 0; i < P; i++) {
if (a[i] == a[(i + 1) % P]) {
p.push_back(a[i]);
i++;
}
}
}
return p[0];
}
ll richest(ll N, ll T, ll S) {
if (T == 1) {
return on2(N);
} else {
return onlogn(N);
}
}
詳細信息
Pretests
Pretest #1:
score: 15
Accepted
time: 619ms
memory: 22988kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 0
Time Limit Exceeded
input:
1000000 20 2000000 29091473
output:
Unauthorized output
result:
Final Tests
Test #1:
score: 15
Accepted
time: 622ms
memory: 22912kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 0
Time Limit Exceeded
input:
1000000 20 2000000 29091471
output:
Unauthorized output