QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#744889#9432. PermutationchrhaaCompile Error//C++141.1kb2024-11-14 00:15:202024-11-14 00:15:21

Judging History

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

  • [2024-11-14 00:15:21]
  • 评测
  • [2024-11-14 00:15:20]
  • 提交

answer

#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
const int N=1005;

int n,a[N];

inline int calc(int p,int x,int y){
	int i,x;

	for(i=1;i<=p;i++) printf("%d ",x);
	for(i=p+1;i<=n;i++) printf("%d ",y);

	putchar('\n');
	fflush(stdout);
	scanf("%d",&x);
	return x;
}

void solve(int l,int r,vector<int> &b){
	if(l==r){
		a[l]=b[0];
		return ;
	}

	random_shuffle(b.begin(),b.end());
	vector<int> c[2];
	int p,i,o,mid=l+r>>1;

	for(i=p=0;i+1<b.size();i++){
		o=calc(mid,b[i],b[i+1]);

		if(o!=1){
			for(o=!o;p<=i;p++)
				c[o].push_back(b[p]);
			
			c[o^1].push_back(b[p]);
			p++;
			i++;
		}
	}

	if(p!=b.size()){
		o=(c[o].size()==mid-l+1);

		for(;p<b.size();p++)
			c[o].push_back(b[p]);
	}

	solve(l,mid,c[0]);
	solve(mid+1,r,c[1]);
}

signed main(){
	int i;
	vector<int> b;
	scanf("%d",&n);

	for(i=1;i<=n;i++) b.push_back(i);
	
	solve(1,n,b);
	putchar(49);

	for(i=1;i<=n;i++) printf(" %d",a[i]);

	putchar('\n');
	fflush(stdout);
	return 0;
}

Details

answer.code: In function ‘int calc(int, int, int)’:
answer.code:12:15: error: declaration of ‘int x’ shadows a parameter
   12 |         int i,x;
      |               ^
answer.code:11:27: note: ‘int x’ previously declared here
   11 | inline int calc(int p,int x,int y){
      |                       ~~~~^
answer.code:19:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   19 |         scanf("%d",&x);
      |         ~~~~~^~~~~~~~~
answer.code: In function ‘int main()’:
answer.code:60:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   60 |         scanf("%d",&n);
      |         ~~~~~^~~~~~~~~