为什么我的代码一直会提交后显示 Wrong Answer.wrong output format Unexpected end of file - token expected。求助万能的大佬帮忙解答和改正。
我写的 SPJ 代码如下:
#include "testlib.h"
#include<bits/stdc++.h>
using namespace std;
int n , m , k , x , y , t;
char c;
string s;
bool a[3005][3005] , answer[3005][3005] , row[3005] , column[3005];
int main(int argc, char *argv[])
{
registerTestlibCmd(argc, argv);
n = inf.readInt();
m = inf.readInt();
k = inf.readInt();
t = 0;
memset(row , 0 , sizeof(row));
memset(column , 0 , sizeof(column));
memset(a , 0 , sizeof(a));
memset(answer , 0 , sizeof(answer));
cout << n << ' ' << m <<endl;
for(int i = 1 ; i <= n ; i++)
{
for(int j = 1 ; j <= m ; j++)
{
c = ans.readChar();
while(c == '\n')
{
c = ans.readChar();
}
a[i][j] |= c - '0';
row[i] |= a[i][j];
column[j] |= a[i][j];
}
}
while(1)
{
if(t > 20000)
{
quitf(_wa , "You can only ask 20000 questions!");
return 0;
}
s = ouf.readToken();
if(s == "number")
{
cout << k << endl;
}
else if(s == "row")
{
x = ouf.readInt();
if(x <= 0 || x >= n)
{
quitf(_wa , "%d is not in the range of [1 , %d]." , x , n);
return 0;
}
if(row[x])
{
cout << 'T' << endl;
}
else
{
cout << 'F' << endl;
}
}
else if(s == "column")
{
x = ouf.readInt();
if(x <= 0 || x >= m)
{
quitf(_wa , "%d is not in the range of [1 , %d]." , x , m);
return 0;
}
if(column[x])
{
cout << 'T' << endl;
}
else
{
cout << 'F' << endl;
}
}
else if(s == "point")
{
x = ouf.readInt();
y = ouf.readInt();
if(x <= 0 || x >= n)
{
quitf(_wa , "%d is not in the range of [1 , %d]." , x , n);
return 0;
}
if(y <= 0 || y >= m)
{
quitf(_wa , "%d is not in the range of [1 , %d]." , y , m);
return 0;
}
if(a[x][y])
{
cout << 'T' << endl;
}
else
{
cout << 'F' << endl;
}
}
else if(s == "answer")
{
cin >> x;
if(x != k)
{
quitf(_wa , "Except %d seats, but found %d seats." , k , x);
return 0;
}
break;
}
else
{
quitf(_wa , "Unknown command.");
return 0;
}
t++;
}
for(int i = 1 ; i <= k ; i++)
{
x = ouf.readInt();
y = ouf.readInt();
if(answer[x][y])
{
quitf(_wa , "Repeatedly outputting the same seat.");
return 0;
}
answer[x][y] = 1;
if(!a[x][y])
{
quitf(_wa , "The seat on (%d , %d) is occupied." , x , y);
return 0;
}
}
quitf(_ok , "Good job!");
return 0;
}
来源题目:T474965。