QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#812040#9156. 百万富翁dvbs200015 631ms25420kbC++141.0kb2024-12-13 11:01:492024-12-13 11:01:49

Judging History

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

  • [2024-12-13 11:01:49]
  • 评测
  • 测评结果:15
  • 用时:631ms
  • 内存:25420kb
  • [2024-12-13 11:01:49]
  • 提交

answer

#include <vector>

// 声明 ask 函数,根据题目要求,这个函数由交互库提供
std::vector<int> ask(std::vector<int> a, std::vector<int> b);

// 实现 richest 函数
int richest(int N, int T, int S) {
    // 向量 a 和 b 用于存储所有需要比较的客户对
    std::vector<int> a;
    std::vector<int> b;

    // 生成所有不同的客户对 (i, j) 其中 i < j
    for(int i = 0; i < N; ++i){
        for(int j = i + 1; j < N; ++j){
            a.push_back(i);
            b.push_back(j);
        }
    }

    // 发送请求并接收返回的结果
    std::vector<int> c = ask(a, b);

    // 创建一个向量用于统计每个客户赢得的次数
    std::vector<int> wins(N, 0);

    // 遍历返回的结果,统计每个客户的胜利次数
    for(int winner : c){
        wins[winner]++;
    }

    // 找到胜利次数最多的客户
    int max_idx = 0;
    for(int i = 1; i < N; ++i){
        if(wins[i] > wins[max_idx]){
            max_idx = i;
        }
    }

    return max_idx;
}

Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 15
Accepted
time: 611ms
memory: 25420kb

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: 631ms
memory: 25140kb

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

result: