QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#510042 | #9156. 百万富翁 | DaniraSilla# | 26.00002 | 2281ms | 99380kb | C++14 | 1.2kb | 2024-08-08 20:47:41 | 2024-08-08 20:47:42 |
Judging History
answer
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include "richest.h"
using namespace std;
typedef long long ll;
int solve1(int n, int s) {
vector<int> a, b;
a.reserve(s);
b.reserve(s);
for (int i = 0; i < n; i++)
for (int j = i + 1; j < n; j++) {
a.push_back(i);
b.push_back(j);
}
vector<int> c = ask(a, b);
vector<vector<bool>> ds(n, vector<bool>(n));
int P = 0;
for (int i = 0; i < n; i++)
for (int j = i + 1; j < n; j++) {
ds[i][j] = (c[P++] == i);
ds[j][i] = !ds[i][j];
}
for (int i = 0; i < n; i++) {
bool ok = true;
for (int j = 0; j < n; j++)
if (j != i && !ds[i][j])
ok = false;
if (ok)
return i;
}
return -1;
}
int richest(int n, int t, int s) {
if (t == 1)
return solve1(n, s);
vector<int> can(n);
for (int i = 0; i < n; i++)
can[i] = i;
while (can.size() > 1) {
vector<int> a(can.size() / 2);
vector<int> b(can.size() / 2);
for (int i = 0; i * 2 + 1 < can.size(); i++) {
a[i] = can[i * 2];
b[i] = can[i * 2 + 1];
}
int d = -1;
if (can.size() % 2)
d = can.back();
can = ask(a, b);
if (d != -1)
can.push_back(d);
}
return can[0];
}
Details
Tip: Click on the bar to expand more detailed information
Pretests
Pretest #1:
score: 15
Accepted
time: 623ms
memory: 20848kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 11
Acceptable Answer
time: 2261ms
memory: 99380kb
input:
1000000 20 2000000 29091473
output:
Partially correct Case 2, 11 / 85, maxt = 20, maxs = 999999 1811468636458994965 0.129412 3823502568050958645
result:
points 0.129412 Partially correct Case 2, 11 / 85, maxt = 20, maxs = 999999
Final Tests
Test #1:
score: 15
Accepted
time: 634ms
memory: 20656kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 11
Acceptable Answer
time: 2281ms
memory: 95284kb
input:
1000000 20 2000000 29091471
output:
Partially correct Case 2, 11 / 85, maxt = 20, maxs = 999999 1811468636458994965 0.129412 3823502568050958645
result:
points 0.129412 Partially correct Case 2, 11 / 85, maxt = 20, maxs = 999999