QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#493100#9156. 百万富翁xieyvzhou123Compile Error//C++144.5kb2024-07-26 19:35:182024-07-26 19:35:18

Judging History

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

  • [2024-07-26 19:35:18]
  • 评测
  • [2024-07-26 19:35:18]
  • 提交

answer

#include "richest.h"
int t[1000010];
//level6 return 500000 numbers
std::vector<int> level6(){
	std::vector<int>a,b,ans;
	for(int i=0;i<1000000;i+=2){a.push_back(i);b.push_back(i+1);}
	ans=ask(a,b);
	return ans;
}
//level5 return 250000 numbers
std::vector<int> level5(){
	std::vector<int>a1=level6();
	std::vector<int>a,b,ans;
	for(int i=0;i<500000;i+=2){
		a.push_back(a1[i]);
		b.push_back(a1[i+1]);
	}
	ans=ask(a,b);
	return ans;
}
//level4 return 125000 numbers
std::vector<int> level4(){
	std::vector<int>a1=level5();
	std::vector<int>a,b,ans;
	for(int i=0;i<250000;i+=2){
		a.push_back(a1[i]);
		b.push_back(a1[i+1]);
	}
	ans=ask(a,b);
	return ans;
}
//level3 return 62500 numbers
std::vector<int> level3(){
	std::vector<int>a1=level4();
	std::vector<int>a,b,ans;
	for(int i=0;i<125000;i+=2){
		a.push_back(a1[i]);
		b.push_back(a1[i+1]);
	}
	ans=ask(a,b);
	return ans;
}
//level2 return 20833 numbers
std::vector<int> level2(){
	std::vector<int>a1=level3();
	std::vector<int>ans;
	std::vector<int>a,b;
	for(int i=0;i<20832;i++){
		int a1l=i*3;int a1r=a1l+2;
		for(int j=a1l;j<=a1r;j++){
			for(int k=a1l;k<j;k++){
				a.push_back(a1[j]);
				b.push_back(a1[k]);
			}
		}
	}
	for(int j=62496;j<62500;j++){
		for(int k=62496;k<j;k++){
			a.push_back(a1[j]);
			b.push_back(a1[k]);
		}
	}
	std::vector<int>res=ask(a,b);
	int tot=0;
	memset(t,0,sizeof t);
	for(int i=0;i<20832;i++){
		int a1l=i*3;int a1r=a1l+2;
		for(int j=a1l;j<=a1r;j++){
			for(int k=a1l;k<j;k++){
				t[res[tot]]++;
				tot++;
			}
		}
		for(int j=a1l;j<=a1r;j++){
			if(t[a1[j]]==2)	ans.push_back(a1[j]);
		}
	}
	for(int j=62496;j<62500;j++){
		for(int k=62496;k<j;k++){
			t[res[tot]]++;
			tot++;
		}
	}
	for(int j=62496;j<62500;j++){
		if(t[a1[j]]==3)	ans.push_back(a1[j]);
	}
	return ans;
}
//level1 return 3472 numbers
std::vector<int> level1(){
	std::vector<int>a1=level2();
	std::vector<int>ans;
	std::vector<int>a,b;
	for(int i=0;i<3471;i++){
		int a1l=i*6;int a1r=a1l+5;
		for(int j=a1l;j<=a1r;j++){
			for(int k=a1l;k<j;k++){
				a.push_back(a1[j]);
				b.push_back(a1[k]);
			}
		}
	}
	for(int j=20826;j<20833;j++){
		for(int k=20826;k<j;k++){
			a.push_back(a1[j]);
			b.push_back(a1[k]);
		}
	}
	std::vector<int>res=ask(a,b);
	int tot=0;
	memset(t,0,sizeof t);
	for(int i=0;i<3471;i++){
		int a1l=i*6;int a1r=a1l+5;
		for(int j=a1l;j<=a1r;j++){
			for(int k=a1l;k<j;k++){
				t[res[tot]]++;
				tot++;
			}
		}
		for(int j=a1l;j<=a1r;j++){
			if(t[a1[j]]==5)	ans.push_back(a1[j]);
		}
	}
	for(int j=20826;j<20833;j++){
		for(int k=20826;k<j;k++){
			t[res[tot]]++;
			tot++;
		}
	}
	for(int j=20826;j<20833;j++){
		if(t[a1[j]]==6)	ans.push_back(a1[j]);
	}
	return ans;
}
//level0 return 183 numbers
std::vector<int> level0(){
	std::vector<int>a1=level1();
	std::vector<int>ans;
	std::vector<int>a,b;
	for(int i=0;i<178;i++){
		int a1l=i*19;int a1r=a1l+18;
		for(int j=a1l;j<=a1r;j++){
			for(int k=a1l;k<j;k++){
				a.push_back(a1[j]);
				b.push_back(a1[k]);
			}
		}
	}
	for(int i=0;i<18;i++){
		int a1l=i*19+3382;int a1r=a1l+17;
		for(int j=a1l;j<=a1r;j++){
			for(int k=a1l;k<j;k++){
				a.push_back(a1[j]);
				b.push_back(a1[k]);
			}
		}
	}
	std::vector<int>res=ask(a,b);
	int tot=0;
	memset(t,0,sizeof t);
	for(int i=0;i<178;i++){
		int a1l=i*19;int a1r=a1l+18;
		for(int j=a1l;j<=a1r;j++){
			for(int k=a1l;k<j;k++){
				t[res[tot]]++;
				tot++;
			}
		}
		for(int j=a1l;j<=a1r;j++){
			if(t[a1[j]]==18)	ans.push_back(a1[j]);
		}
	}
	for(int i=0;i<18;i++){
		int a1l=i*19+3382;int a1r=a1l+17;
		for(int j=a1l;j<=a1r;j++){
			for(int k=a1l;k<j;k++){
				t[res[tot]]++;
				tot++;
			}
		}
	}
	for(int i=0;i<18;i++){
		int a1l=i*19+3382;int a1r=a1l+17;
		for(int j=a1l;j<=a1r;j++){
			if(t[a1[j]]==17)	ans.push_back(a1[j]);
		}
	}
	return ans;
}
int richest(int N,int S,int T){
	if(N==1000){
		std::vector<int>a,b;
		int w=0;
		for(int i=0;i<1000;i++){
			for(int j=0;j<i;j++){
				a.push_back(i);
				b.push_back(j);
				w++;
			}
		}
		std::vector<int>c=ask(a,b);
		for(int i=0;i<w;i++){
			t[c[i]]++;
		}
		for(int i=0;i<1000;i++){
			if(t[i]==999)	return i;
		}
	}
	else{
		std::vector<int>a1;
		a1=level0();
		std::vector<int>a,b;
		int w=0;
		for(int i=0;i<183;i++){
			for(int j=0;j<i;j++){
				a.push_back(a1[i]);
				b.push_back(a1[j]);
				w++;
			}
		}
		std::vector<int>c=ask(a,b);
		memset(t,0,sizeof t);
		for(int i=0;i<w;i++){
			t[c[i]]++;
		}
		for(int i=0;i<183;i++){
			if(t[a1[i]]==182)	return a1[i];
		}
	}
}

Details

answer.code: In function ‘std::vector<int> level2()’:
answer.code:65:9: error: ‘memset’ was not declared in this scope
   65 |         memset(t,0,sizeof t);
      |         ^~~~~~
answer.code:2:1: note: ‘memset’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’?
    1 | #include "richest.h"
  +++ |+#include <cstring>
    2 | int t[1000010];
answer.code: In function ‘std::vector<int> level1()’:
answer.code:111:9: error: ‘memset’ was not declared in this scope
  111 |         memset(t,0,sizeof t);
      |         ^~~~~~
answer.code:111:9: note: ‘memset’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’?
answer.code: In function ‘std::vector<int> level0()’:
answer.code:160:9: error: ‘memset’ was not declared in this scope
  160 |         memset(t,0,sizeof t);
      |         ^~~~~~
answer.code:160:9: note: ‘memset’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’?
answer.code: In function ‘int richest(int, int, int)’:
answer.code:222:17: error: ‘memset’ was not declared in this scope
  222 |                 memset(t,0,sizeof t);
      |                 ^~~~~~
answer.code:222:17: note: ‘memset’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’?
answer.code:230:1: warning: control reaches end of non-void function [-Wreturn-type]
  230 | }
      | ^