交互库如下,一直显示 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);
}