QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#502062 | #9156. 百万富翁 | maxrgby# | 0 | 0ms | 0kb | C++14 | 1.7kb | 2024-08-03 00:46:47 | 2024-08-03 00:46:51 |
answer
#include <bits/stdc++.h>
#include "richest.h"
using namespace std;
//int arr[1000];
// vector<int> ask(vector<int> a, vector<int> b){
// vector<int> ret;
// for(int i = 0;i < a.size();i++){
// if(arr[a[i]] > arr[b[i]]){
// ret.push_back(a[i]);
// }else{
// ret.push_back(b[i]);
// }
// }
// return ret;
// }
int richest(int n, int t, int s) {
assert(t >= ceil(log2(n)));
assert(s >= 2*n);
vector<int> a,b,c;
set<int> nums;
for(int i = 0;i < n;i++){
for(int j = i+1;j < n;j++){
a.push_back(i);
b.push_back(j);
}
nums.insert(i);
}
c = ask(a,b);
// cout << "asz=" << a.size() << "bsz=" << b.size() << "csz=" << c.size() << endl;
// assert(a.size() == b.size());
// assert(b.size() == c.size());
for(int i = 0;i < c.size();i++){
if(c[i] != a[i]){
nums.erase(a[i]);
}else{
nums.erase(b[i]);
}
}
assert(nums.size() == 1);
return *nums.begin();
// set<int> nums;
// for(int i = 0;i < n;i++){
// nums.insert(i);
// }
// vector<int> a,b,c;
// int sum = 0;
// while(t--){
// a.clear();
// b.clear();
// c.clear();
// int i = 0;
// for(auto it = nums.begin();it != nums.end();it++,i++){
// if(i&1){
// b.push_back(*it);
// }else{
// a.push_back(*it);
// }
// }
// if(a.size() != b.size()){
// b.push_back({*nums.rbegin()});
// }
// sum += a.size();
// c = ask(a,b);
// nums.clear();
// for(auto i : c){
// nums.insert(i);
// }
// //cout << endl;
// }
// //cout << "sum=" << sum << endl;
//return *nums.begin();
}
// int main(){
// int n,t,s;
// cin >> n >> t >> s;
// for(int i = 0;i < n;i++){
// cin >> arr[i];
// }
// cout << richest(n,t,s) << endl;
// }
Details
Tip: Click on the bar to expand more detailed information
Pretests
Pretest #1:
score: 0
Runtime Error
input:
1000 1 499500 957319859
output:
Unauthorized output
result:
Pretest #2:
score: 0
Memory Limit Exceeded
input:
1000000 20 2000000 29091473
output:
Unauthorized output
result:
Final Tests
Test #1:
score: 0
Runtime Error
input:
1000 1 499500 957319857
output:
Unauthorized output
result:
Test #2:
score: 0
Memory Limit Exceeded
input:
1000000 20 2000000 29091471
output:
Unauthorized output