QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#498233 | #9156. 百万富翁 | biuld# | 15 | 634ms | 29036kb | C++14 | 1.4kb | 2024-07-30 09:33:52 | 2024-07-30 09:33:52 |
Judging History
answer
#include "richest.h"
#include<bits/stdc++.h>
using namespace std;
const int N = 1e3;
const int M = 1e6;
vector<int> a, b, c;
int w[N + 5][N + 5];
bool vis[M + 5];
int cnt;
int richest(int n, int t, int s){
if(t == 1){
a.clear();
b.clear();
for(int i = 0; i < n; ++ i){
for(int j = i + 1; j < n; ++ j){
a.push_back(i);
b.push_back(j);
}
}
c = ask(a, b);
for(int i = 0; i < a.size(); ++ i){
w[a[i]][b[i]] = w[b[i]][a[i]] = c[i];
// cout << a[i] << ' ' << b[i] << ": " << c[i] << '\n';
// cout << w[a[i]][b[i]] << '\n';
}
int now = 0;
for(int i = 1; i < n; ++ i){
// cout << now << '-' << i << ':' << w[now][i] << '\n';
if(w[now][i] == i) now = i;
}
// cout << now << '\n';
return now;
}
for(int i = 0; i < n; ++ i) vis[i] = 0;
cnt = 0;
int ss = s / t;
while(t --){
if(cnt == n - 1) break;
a.clear(); b.clear();
for(int i = 1; i <= ss; ++ i){
int x = rand() % n;
while(vis[x]) x = rand() % n;
int y = rand() % n;
while(vis[y] || x == y) y = rand() % n;
a.push_back(x);
b.push_back(y);
}
c = ask(a, b);
for(int i = 0; i < c.size(); ++ i){
if(a[i] == c[i]){
if(!vis[b[i]]) ++ cnt;
vis[b[i]] = 1;
}
if(b[i] == c[i]){
if(!vis[a[i]]) ++ cnt;
vis[a[i]] = 1;
}
}
}
int now = 0;
while(vis[now]) ++ now;
return now;
}
详细
Pretests
Pretest #1:
score: 15
Accepted
time: 634ms
memory: 29036kb
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: 624ms
memory: 28476kb
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