QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#740890 | #9156. 百万富翁 | K8He | 100 ✓ | 3122ms | 102140kb | C++20 | 1.8kb | 2024-11-13 12:07:54 | 2024-11-13 12:07:54 |
Judging History
answer
#include "richest.h"
#include <bits/stdc++.h>
#define _for(i, a, b) for (int i = a; i <= b; ++i)
#define for_(i, a, b) for (int i = a; i >= b; --i)
#define far(i, vec) for (auto i : vec)
#define bdmd int mid = (l + r) >> 1
typedef long double ldb;
typedef long long ll;
typedef double db;
typedef std::pair <int, int> pii;
typedef std::pair <ll, ll> pll;
std::vector <int> D ({ 500000, 250000, 125000, 62500, 20832, 3472, 183, 1 });
int richest(int N, int T, int S) {
std::vector <int> A, C;
_for (i, 0, N - 1) {
A.emplace_back (i);
C.emplace_back (0);
}
if (N == 1000) {
std::vector <int> qi, qj;
_for (i, 0, N - 1) _for (j, i + 1, N - 1)
qi.emplace_back (i), qj.emplace_back (j);
std::vector <int> ans = ask (qi, qj);
int tot = 0;
_for (i, 0, N - 1) _for (j, i + 1, N - 1)
++C[ans[tot]], ++tot;
_for (i, 1, N) if (C[i] == N - 1)
return i;
return -1;
}
far (p, D) {
std::vector <std::vector <int> > off (p);
int m = A.size ();
_for (i, 0, m - 1) {
off[i % p].emplace_back (A[i]);
C[A[i]] = 0;
}
std::vector <int> ().swap (A);
std::vector <int> qi, qj;
far (B, off) {
int l = B.size ();
_for (i, 0, l - 1) _for (j, i + 1, l - 1)
qi.emplace_back (B[i]), qj.emplace_back (B[j]);
}
std::vector <int> ans = ask (qi, qj);
int tot = 0;
far (B, off) {
int l = B.size ();
_for (i, 0, l - 1) _for (j, i + 1, l - 1)
++C[ans[tot]], ++tot;
_for (i, 0, l - 1) if (C[B[i]] == l - 1)
A.emplace_back (B[i]);
}
}
return A[0];
}
Details
Tip: Click on the bar to expand more detailed information
Pretests
Pretest #1:
score: 15
Accepted
time: 598ms
memory: 21912kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 85
Accepted
time: 3114ms
memory: 102136kb
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: 602ms
memory: 23156kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 85
Accepted
time: 3122ms
memory: 102140kb
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