QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#510036 | #9156. 百万富翁 | DaniraSilla# | 15 | 622ms | 20740kb | C++14 | 863b | 2024-08-08 20:43:09 | 2024-08-08 20:43:11 |
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);
}
Details
Tip: Click on the bar to expand more detailed information
Pretests
Pretest #1:
score: 15
Accepted
time: 621ms
memory: 20740kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 0
Memory Limit Exceeded
input:
1000000 20 2000000 29091473
output:
Unauthorized output
result:
Final Tests
Test #1:
score: 15
Accepted
time: 622ms
memory: 20432kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 0
Memory Limit Exceeded
input:
1000000 20 2000000 29091471
output:
Unauthorized output