【SPJ】Wrong Output Format问题求助
  • 板块学术版
  • 楼主66xyyd
  • 当前回复11
  • 已保存回复11
  • 发布时间2023/8/24 08:50
  • 上次更新2023/11/3 01:36:57
查看原帖
【SPJ】Wrong Output Format问题求助
946515
66xyyd楼主2023/8/24 08:50

我写了一道交互题。

interactive_lib.cpp:

#include<iostream>
#include<algorithm>
namespace{
	using namespace std;
	static int ans=0;
	static int n,q;
	static int nowx;
}
extern "C++"{
	extern int guess(int n,int q,bool (*queryW)(int x),bool (*queryH)());
}
bool queryH(){
	//query('H')
	if(q<=0){
		cout << "-1" << endl;
		cout << flush;
		exit(1);
	}
	q--;
	nowx<<=1;
	return (ans>=(nowx>>1) && ans<=min(nowx,n));
}
bool queryW(int x){
	//query('W',x);
	if(x<1 || x>n || q<=0){
		cout << "-1" << endl;
		cout << flush;
		exit(1);
	}
	q--;
	nowx=x;
	return (ans==x);
}
int main(){
	cin >> ::n >> ::q >> ::ans;
	nowx=1;
	int res=guess(n,q,queryW,queryH);
	cout << ((res^(res<<17)^(res<<1|1))) << endl;
	cout << flush;
	return 0;
}

checker.cpp:

#ifndef uint64_t//别怪我,但是testlib没有这个就报错
#define uint64_t size_t
#endif
#include "testlib.h"
#include<iostream>
using namespace std;
int main(int argc,char ** argv){
	registerTestlibCmd(argc,argv);
	int n=inf.readInt(0,1000000);
	int q=inf.readInt(0,1000000);
	int anss=inf.readInt(1,n);
	cout << n << " " << q << " " << anss <<endl;
	int pa=ans.readInt();
	anss=ouf.readInt();
	if(anss==pa){
		quitf(_ok,"Test pass.");
	} else{
		quitf(_wa,"Wrong answer.ans=%d;ouf=%d",pa,anss);
	}
	return 0;
}

我交了一发进行测试,结果:

Wrong Answer.wrong output format Unexpected end of file - int32 expected

哪里出了问题?我应该怎么修改?第一次出交互题,多多谅解。(我在本地测试的时候都是Test pass.,但是checker.cpp的输出都输出到控制台了)

2023/8/24 08:50
加载中...