交互库求助
  • 板块学术版
  • 楼主sherry_lover
  • 当前回复1
  • 已保存回复1
  • 发布时间2025/2/6 22:50
  • 上次更新2025/2/7 10:51:53
查看原帖
交互库求助
686281
sherry_lover楼主2025/2/6 22:50

交互库如下,一直显示 Time Limit Exceeded.wrong output format Unexpected end of file - int32 expected。

#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;
int n,q,t,cnt,a[2005];
char c;
int main(int argc, char ** argv){
	registerInteraction(argc, argv);
	n = inf.readInt(),q = inf.readInt();
	random_device rd;
	mt19937 rng(rd());
	for(int i = 1;i <= n;i++) a[i] = i;
    shuffle(a+1,a+n+1,rng);
	for(int i = 1;i <= n;i++) cnt += a[i]*i;
	cout.flush();
	bool found = false;
	while(t < q && !found)
	{
		c = ouf.readChar();
//		int x = ouf.readInt(1,1000000000);
//		if(x == cnt) found = true;
//		break;		
		// c = '0';
		// while(c != '?' && c != '!') c = ouf.readChar();
		if(c == '?')
		{
			t++;
			int x = ouf.readInt();
			int y = ouf.readInt();
			int tot = 0;
			for(int i = 1;i <= x;i++) tot += (a[x] <= y);
			cout << tot << endl;
		}
		else
		{
			int x = ouf.readInt();
			if(x == cnt) found = true;
			break;
		}
		cout.flush();
	}
	if(!found) quitf(_wa, "The answer is wrong.");
	else quitf(_ok, "The right answer is %d.",cnt);
}
2025/2/6 22:50
加载中...