QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#502285#9156. 百万富翁phlap#0 331ms101644kbC++201.4kb2024-08-03 03:03:192024-08-03 03:03:19

Judging History

你现在查看的是最新测评结果

  • [2024-08-03 03:03:19]
  • 评测
  • 测评结果:0
  • 用时:331ms
  • 内存:101644kb
  • [2024-08-03 03:03:19]
  • 提交

answer

#include "richest.h"
#include <bits/stdc++.h>
using namespace std;

int richest(int n, int t, int s){
  int block=sqrt(n);
  vector<int> vec[block];
  for(int i=0; i<n; i++) vec[i%block].push_back(i);
  int lastguess[block];
  int found[block], cnt=0;
  memset(found, 0, sizeof found);
  vector<int> query1, query2, result;
  while(cnt<block){
    query1.clear(), query2.clear(), result.clear();
    for(int i=0; i<block; i++){
      if(found[i]) continue;
      lastguess[i]=vec[i][0];
      for(int j=1; j<vec[i].size(); j++){
        query1.push_back(vec[i][0]);
        query2.push_back(vec[i][j]);
      }
    }
    if(!query1.empty()) result=ask(query1, query2);
    for(int i=0; i<block; i++) vec[i].clear();
    for(auto i: result) if(i!=lastguess[i%block]) vec[i%block].push_back(i);
    for(int i=0; i<block; i++) if(vec[i].empty()) found[i]=1, cnt++;
  }
  vector<int> final;
  for(int i=0; i<block; i++) final.push_back(lastguess[i]);
  query1.clear(), query2.clear(), result.clear();
  for(int i=0; i<block; i++){
    for(int j=0; j<i; j++) query1.push_back(final[i]), query2.push_back(final[j]);
  }
  result=ask(query1, query2);
  int isless[n];
  memset(isless, 0, sizeof isless);
  for(int i=0; i<query1.size(); i++){
    if(result[i]==query1[i]) isless[query2[i]]=1;
    else isless[query1[i]]=1;
  }
  for(auto i: result) if(!isless[i]) return i;
  return -1;
}

详细


Pretests

Pretest #1:

score: 0
Wrong Answer
time: 1ms
memory: 8148kb

input:

1000 1 499500 957319859

output:

Too many queries
1294109832092195181
0.000000
6906350380861515327

result:

points 0.0 Too many queries

Pretest #2:

score: 0
Wrong Answer
time: 331ms
memory: 101644kb

input:

1000000 20 2000000 29091473

output:

Too many total elements in queries
1469670942222006797
0.000000
6906350380861515327

result:

points 0.0 Too many total elements in queries


Final Tests

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 8136kb

input:

1000 1 499500 957319857

output:

Too many queries
1294109832092195181
0.000000
6906350380861515327

result:

points 0.0 Too many queries

Test #2:

score: 0
Wrong Answer
time: 311ms
memory: 101516kb

input:

1000000 20 2000000 29091471

output:

Too many total elements in queries
1469670942222006797
0.000000
6906350380861515327

result:

points 0.0 Too many total elements in queries