QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#507190#9156. 百万富翁juruoA77.99996 2074ms111880kbC++145.9kb2024-08-06 13:01:072024-08-06 13:01:07

Judging History

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

  • [2024-08-06 13:01:07]
  • 评测
  • 测评结果:77.99996
  • 用时:2074ms
  • 内存:111880kb
  • [2024-08-06 13:01:07]
  • 提交

answer

#include <bits/stdc++.h>
#include "richest.h"
using std::bitset;
using std::cout;
using std::deque;
using std::endl;
using std::greater;
using std::lower_bound;
using std::make_pair;
using std::map;
using std::max;
using std::min;
using std::multimap;
using std::multiset;
using std::nth_element;
using std::pair;
using std::priority_queue;
using std::queue;
using std::reverse; 
using std::set;
using std::sort;
using std::sqrt;
using std::stable_sort;
using std::string;
using std::swap;
using std::unique;
using std::upper_bound;
using std::vector;
typedef int li;
typedef long double lf;

inline li read(){
	li ans = 0, f = 1;
	char ch = getchar();
	while(ch < '0' || ch > '9'){
		f = (ch == '-') ? -1 : 1;
		ch = getchar();
	}
	while(ch <= '9' && ch >= '0'){
		ans = ans * 10 + (ch ^ 48);
		ch = getchar();
	}
	return ans * f;
} 

vector<int> v1, v2, v3;
li a[2010][2010];
vector<li> rest, rest2;
std::map<pair<li, li>, li> mp;

int richest(li n, li t, li s){
//		FILE *out = fopen("www.ww", "w");
	//	cout << n << " " << t << " " << s << endl;
	v1.clear(), v2.clear(), v3.clear(), rest2.clear(), rest.clear(), mp.clear();
	memset(a, 0, sizeof a);
	if(t == 1){
		v1.clear(),  v2.clear();
		for(li i = 1; i <= n; i++){
			for(li j = i + 1; j <= n; j++){
				v1.push_back(i - 1);
				v2.push_back(j - 1);
			}
		}	
		v3 = ask(v1, v2);
		li now = 0;
		for(li i = 1; i <= n; i++){
			for(li j = i + 1; j <= n; j++){
				if(v3[now] + 1 == i) a[i][j] = 1;
				else a[i][j] = 0;
				a[j][i] = !a[i][j];
				//				fprintf(out, "%d %d %d %d\n", v1[now], v2[now], v3[now] + 1, a[i][j]);
				now++;
			}
			a[i][i] = 1;
		}
		for(li i = 1; i <= n; i++){
			li cnt = 0;
			for(li j = 1; j <= n; ++j) cnt += a[i][j];
			//			fprintf(out, "cnt %d = %d\n", i, cnt);
			if(cnt == n){
				//				fclose(out);
				return i - 1;
			}
		}
	}
	mp.clear();
	//	fprintf(out, "?"); fflush(out);
	rest.clear();
	//	li cnt = 0;
	for(li i = 0; i < n; i++) rest.push_back(i);
	for(li i = 1; i <= 12; i++){
		//		if(i == 10 || i == 12) continue;
		if(i == 11 || i == 9 || i == 7) mp.clear();
		v1.clear(), v2.clear();
		//		fprintf(out, "i = %d, size = %d\n", i, (li)rest.size());
		for(li j = 0; j < (li)rest.size(); j += 2){
			if(j + 1 < (li)rest.size()){
				if(i == 12 || i == 10 || i == 8 || i == 6){
					rest2.push_back(v3[mp[{rest[j], rest[j + 1]}]]);
					//					fprintf(out, "winner %d %d = %d(%d)\n", rest[j], rest[j + 1], mp[{rest[j], rest[j + 1]}], v3[mp[{rest[j], rest[j + 1]}]]);
				} else{
					v1.push_back(rest[j]), v2.push_back(rest[j + 1]);
				}
			}
		}
		if(i == 11 || i == 9 || i == 7 || i == 5){
			li add = (i == 9) ? 4 : 4;
			//			fprintf(out, "%d %d\n",(li) rest.size(), cnt + (li)v1.size());
			for(li j = 0; j < (li)rest.size(); j += add){
				for(li x = 0; x < add && j + x + 1 < (li)rest.size(); x += 2){
					for(li y = x + 2; y < add && j + y < (li)rest.size(); y += 2){
//						fprintf(out, "%d %d\n", x, y);
						for(li k = y; k <= y + 1 && j + k < (li)rest.size(); k++){
							v1.push_back(rest[j + x]), v2.push_back((rest[j + k]));
							mp[{rest[j + x], rest[j + k]}] = v1.size() - 1;
							v1.push_back(rest[j + x + 1]), v2.push_back((rest[j + k]));
							mp[{rest[j + x + 1], rest[j + k]}] = v1.size() - 1;
						}
					}
				}
				//				fprintf(out, "rest %d = %d\n", 0 + j, rest[0 + j]);
				//				fprintf(out, "rest %d = %d\n", 1 + j, rest[1 + j]);
				//				fprintf(out, "rest %d = %d\n", 2 + j, rest[2 + j]);
				//				fprintf(out, "rest %d = %d\n", 3 + j, rest[3 + j]);
//				if(j + 2 < (li)rest.size()){
//					v1.push_back(rest[j]), v2.push_back((rest[j + 2]));
//					mp[{rest[j], rest[j + 2]}] = v1.size() - 1;
//					//					fprintf(out, "mp %d %d = %d\n", rest[j], rest[j + 2], mp[{rest[j], rest[j + 2]}]);
//					v1.push_back(rest[j + 1]), v2.push_back((rest[j + 2]));
//					mp[{rest[j + 1], rest[j + 2]}] = v1.size() - 1;
//					//					fprintf(out, "mp %d %d = %d\n", rest[j + 1], rest[j + 2], mp[{rest[j + 1], rest[j + 2]}]);
//					if(j + 3 < (li)rest.size()){
//						v1.push_back(rest[j]), v2.push_back((rest[j + 3]));
//						mp[{rest[j], rest[j + 3]}] = v1.size() - 1;
//						//						fprintf(out, "mp %d %d = %d\n", rest[j], rest[j + 3], mp[{rest[j], rest[j + 3]}]);
//						v1.push_back(rest[j + 1]), v2.push_back((rest[j + 3]));
//						mp[{rest[j + 1], rest[j + 3]}] = v1.size() - 1;
//						//						fprintf(out, "mp %d %d = %d\n", rest[j + 1], rest[j + 3], mp[{rest[j + 1], rest[j + 3]}]);
//					}
//				}
			}
			//			fprintf(out, "%d %d\n",(li) rest.size(), cnt + (li)v1.size());
		}
		//		fprintf(out, "%d %d\n", (li)v1.size(), (li)v2.size()); fflush(out);
		if(i != 12 && i != 10 && i != 8 && i != 6) v3 = ask(v1, v2);
		//		if(i != 12 && i != 10 && i != 8 && i != 6) cnt += v3.size();
		li now = 0;
		if(1) for(li j = 0; j < (li)rest.size(); j += 2){
			if(j + 1 < (li)rest.size()){
				if(i != 12 && i != 10 && i != 8 && i != 6){
					rest2.push_back((v3[now]));
					now++;
				}
			} else{
				rest2.push_back(rest[j]);
			}
		}
		v1.clear(), v2.clear();
		rest = rest2;
		//		fprintf(out, "%d %d\n", (li)rest.size(), cnt); fflush(out);
		rest2.clear();
	}
	//	fprintf(out, "%d\n", (li)rest.size()); fflush(out);
	for(li i = 0; i < (li)rest.size(); i++){
		for(li j = i + 1; j < (li)rest.size(); j++){
			v1.push_back(rest[i]), v2.push_back((rest[j]));
		}
	}
	v3 = ask(v1, v2);
	li now = 0;
	li nn = rest.size();
	for(li i = 0; i < nn; i++){
		for(li j = i + 1; j < nn; j++){
			a[i][j] = 0;
			if(v3[now] == rest[i]) a[i][j] = 1;
			now++;
			a[j][i] = !a[i][j];
		}
		a[i][i] = 1;
	}
	for(li i = 0; i < nn; i++){
		li cnt = 0;
		for(li j = 0; j < nn; j++){
			cnt += a[i][j];
		}
		if(cnt == nn) return rest[i];
	}
	v1.clear(), v2.clear();
	assert(0 > 1);
	return 1;
}

//int main(){
//	// freopen("wonderful.ans", "r", stdin);
//	// freopen("www.ww", "w", stdout); 
//	
//	return 0;
//} 

詳細信息


Pretests

Pretest #1:

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

input:

1000 1 499500 957319859

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Pretest #2:

score: 63
Acceptable Answer
time: 2034ms
memory: 111680kb

input:

1000000 20 2000000 29091473

output:

Partially correct Case 2, 63 / 85, maxt = 9, maxs = 1091899
15924754611964940863
0.741176
16601290867448354019

result:

points 0.741176 Partially correct Case 2, 63 / 85, maxt = 9, maxs = 1091899


Final Tests

Test #1:

score: 15
Accepted
time: 629ms
memory: 40376kb

input:

1000 1 499500 957319857

output:

Correct
7127326332295218295
1.000000
1331569654267968081

result:

points 1.0 Correct

Test #2:

score: 63
Acceptable Answer
time: 2074ms
memory: 111880kb

input:

1000000 20 2000000 29091471

output:

Partially correct Case 2, 63 / 85, maxt = 9, maxs = 1091899
15924754611964940863
0.741176
16601290867448354019

result:

points 0.741176 Partially correct Case 2, 63 / 85, maxt = 9, maxs = 1091899