QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#502385#9156. 百万富翁alexz1205#15 626ms85856kbC++141.5kb2024-08-03 04:57:502024-08-03 04:57:52

Judging History

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

  • [2024-08-03 04:57:52]
  • 评测
  • 测评结果:15
  • 用时:626ms
  • 内存:85856kb
  • [2024-08-03 04:57:50]
  • 提交

answer

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

int richest(int N, int T, int S){
	if (T == 1){
		vector<int> a, b;
		for (int x = 0; x < N; x ++){
			for (int y = x+1; y < N; y ++){
				a.push_back(x);
				b.push_back(y);
			}
		}
		vector<int> c = ask(a, b);
		int ma = 0;
		int check = 0, cur = 0;
		for (int x = 1; x < N; x ++){
			cur += N-x;
			if (c[check + x-ma-1] == x){
				ma = x;
				check = cur;
			}
		}
		return ma;
	}else {
		vector<int> rem;
		for (int x = 0; x < N; x ++){
			rem.push_back(x);
		}
		vector<int> a, b, c;
		for (int x = 0; x < 20; x ++){
			if (rem.size() == 1){
				break;
			}
			for (int i = 0; i <= rem.size()/2; i ++){
				a.push_back(rem[2*i]);
				b.push_back(rem[(2*i+1) % rem.size()]);
			}
			c = ask(a, b);
			vector<int> nextRem;
			if (rem.size() % 2 == 1){
				if (c[0] == c.back()){
					nextRem.push_back(rem[0]);
				}else if (c[0] == rem[0]){
					nextRem.push_back(rem.back());
				}else if (c.back() == rem[0]){
					nextRem.push_back(rem[1]);
				}else {
					nextRem.push_back(rem.back());
					nextRem.push_back(rem[1]);
				}
			}else {
				if (c[0] == rem[0]){
					nextRem.push_back(rem[0]);
				}else {
					nextRem.push_back(rem[1]);
				}
			}
			for (int i = 1; i < rem.size()/2; i ++){
				if (c[i] == rem[2*i]){
					nextRem.push_back(rem[2*i]);
				}else {
					nextRem.push_back(rem[2*i + 1]);
				}
			}
			swap(nextRem, rem);
		}
		return rem[0];
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 15
Accepted
time: 626ms
memory: 25260kb

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 0
Wrong Answer
time: 122ms
memory: 85856kb

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: 15
Accepted
time: 613ms
memory: 25276kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 0
Wrong Answer
time: 108ms
memory: 85164kb

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