QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#491868 | #9156. 百万富翁 | 5toubun_no_hanayome# | 100 ✓ | 2997ms | 108332kb | C++14 | 2.4kb | 2024-07-26 00:12:36 | 2024-07-26 00:12:36 |
Judging History
answer
#include<bits/stdc++.h>
#include "richest.h"
#define rep(i, a, b) for(int i = (a);i <= (b);++i)
#define per(i, a, b) for(int i = (a);i >= (b);--i)
#define lc (k << 1)
#define rc (k << 1 | 1)
#define lowbit(x) ((x) & -(x))
#define odd(x) ((x) & 1)
#define even(x) (!odd(x))
#define fir first
#define sec second
#define pb push_back
#define il inline
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define i128 __int128
#define f128 __float128
#define pii pair<int, int>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << "In Line " << __LINE__ << " the " << #x << " = " << (x) << "\n"
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<class T> using vc = vector<T>;
template<class Tx, class Ty>
il void chkmx(Tx& x, const Ty y) {x = max<common_type_t<Tx, Ty>>(x, y);}
template<class Tx, class Ty>
il void chkmn(Tx& x, const Ty y) {x = min<common_type_t<Tx, Ty>>(x, y);}
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f3f3fll;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
const int N = 1e6 + 5;
int ct[N];
int richest(int n, int t, int s) {
if(t == 1) {
vc<int> a, b;
rep(i, 1, n) {
rep(j, i + 1, n)
a.pb(i - 1), b.pb(j - 1);
}
vc<int> c = ask(a, b);
map<int, int> mp;
int ans = -1;
for(int& i : c) {
if(++mp[i] == n - 1)
ans = i;
}
return ans;
}
vc<int> a, b, c, id(n);
iota(all(id), 0);
int B[8] = {500000, 250000, 125000, 62496, 20832, 3472, 183, 1};
rep(i, 1, 8) {
int t = B[i - 1];
vc<vc<int>> v(t);
rep(j, 0, SZ(id) - 1)
v[j % t].pb(id[j]);
a.clear(), b.clear(), id.clear();
rep(j, 0, t - 1) {
rep(k, 0, SZ(v[j]) - 1) {
rep(l, k + 1, SZ(v[j]) - 1)
a.pb(v[j][k]), b.pb(v[j][l]);
}
}
c = ask(a, b);
for(int& j : c)
ct[j] = 0;
int p = 0;
rep(j, 0, t - 1) {
int mx = -1;
rep(k, 1, (SZ(v[j]) - 1) * SZ(v[j]) / 2) {
++ct[c[p]];
if(mx == -1 || ct[c[p]] > ct[mx])
mx = c[p];
++p;
}
id.pb(mx);
}
}
return id[0];
}
詳細信息
Pretests
Pretest #1:
score: 15
Accepted
time: 746ms
memory: 22028kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 85
Accepted
time: 2853ms
memory: 108332kb
input:
1000000 20 2000000 29091473
output:
Correct Case 2, 85 / 85, maxt = 8, maxs = 1099944 7610580723948932399 1.000000 1331569654267968081
result:
points 1.0 Correct Case 2, 85 / 85, maxt = 8, maxs = 1099944
Final Tests
Test #1:
score: 15
Accepted
time: 750ms
memory: 25376kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 85
Accepted
time: 2997ms
memory: 101848kb
input:
1000000 20 2000000 29091471
output:
Correct Case 2, 85 / 85, maxt = 8, maxs = 1099944 7610580723948932399 1.000000 1331569654267968081
result:
points 1.0 Correct Case 2, 85 / 85, maxt = 8, maxs = 1099944