QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#492783#9156. 百万富翁Felix72100 ✓2354ms102160kbC++141.4kb2024-07-26 16:04:342024-07-26 16:04:35

Judging History

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

  • [2024-07-26 16:04:35]
  • 评测
  • 测评结果:100
  • 用时:2354ms
  • 内存:102160kb
  • [2024-07-26 16:04:34]
  • 提交

answer

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

const int N = 1000010;
int pos[N], cnt, nxt[N], tot, siz[N], score[N];
int richest(int n, int t, int s)
{
	if(n <= 1000)
	{
		vector < int > a, b, c; int cnt[1010] = {0};
		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 < (int)c.size(); ++i) ++cnt[c[i]];
		for(int i = 0; i < n; ++i) if(cnt[i] == n - 1) return i;
	}
	else
	{
		int blo[15] = {0, 2, 2, 2, 2, 3, 6, 19, 183};
		int ext[15] = {0, 0, 0, 0, 0, 1, 1, 5, 0};
		int spe[15] = {0, 0, 0, 0, 0, 4, 7, 18, 0};
		for(int i = 1; i <= n; ++i) pos[i] = i - 1; cnt = n;
		for(int i = 1; i <= 8; ++i)
		{
			for(int j = 0; j < n; ++j) score[j] = 0;
			vector < int > a, b, c;
			for(int l = 1; l <= cnt; ++l)
			{
				int B = 0, r = 0;
				if(ext[i]) --ext[i], B = spe[i];
				else B = blo[i];
				r = l + B - 1;
				for(int j = l; j <= r; ++j) siz[j] = B;
				for(int p1 = l; p1 <= r; ++p1)
					for(int p2 = p1 + 1; p2 <= r; ++p2)
						a.push_back(pos[p1]), b.push_back(pos[p2]);
				l = r;
			}
			c = ask(a, b);
			for(int j = 0; j < (int)c.size(); ++j) ++score[c[j]];
			tot = 0;
			for(int j = 1; j <= cnt; ++j) if(score[pos[j]] == siz[j] - 1) nxt[++tot] = pos[j];
			cnt = tot; for(int j = 1; j <= cnt; ++j) pos[j] = nxt[j];
		}
		return pos[1];
	}
}
/*
2 2 2 2 3 6 19 183
*/

详细


Pretests

Pretest #1:

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

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 85
Accepted
time: 2354ms
memory: 102160kb

input:

1000000 20 2000000 29091473

output:

Correct Case 2, 85 / 85, maxt = 8, maxs = 1099944
7610580723948932399
1.000000
1331569654267968081

result:

points 1.0 Correct Case 2, 85 / 85, maxt = 8, maxs = 1099944


Final Tests

Test #1:

score: 15
Accepted
time: 625ms
memory: 25284kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 85
Accepted
time: 2235ms
memory: 94348kb

input:

1000000 20 2000000 29091471

output:

Correct Case 2, 85 / 85, maxt = 8, maxs = 1099944
7610580723948932399
1.000000
1331569654267968081

result:

points 1.0 Correct Case 2, 85 / 85, maxt = 8, maxs = 1099944