求助 SPJ
  • 板块灌水区
  • 楼主tbdsh
  • 当前回复5
  • 已保存回复5
  • 发布时间2022/12/30 10:50
  • 上次更新2023/10/24 06:09:16
查看原帖
求助 SPJ
752485
tbdsh楼主2022/12/30 10:50

这一份SPJ 代码为什么会输出这个:Wrong output format Extra information in the output file

代码如下:

#include "testlib.h"
#include<bits/stdc++.h>

using namespace std;
int m;
bool checka(string s){
  int len = s.size();
  for (int i = 0, j = len - 1; i < j; i++, j--){
    if (s[i] != s[j]){
      return 0;
    }
  }
  return 1;
}
bool checkb(string s){
  int len = s.size();
  for (int i = 0; i < len - 1; i += 2){
    char q = s[i];
    for (int j = 1; j <= m; j++){
      q++;
      if (q == 'z' + 1){
        q = 'a';
      }
    }
    if (q != s[i + 1]){
      return 0;
    }
  }
  return 1;
}
int change(string a, string b){
  int cnt = 0, len = a.size();
  for (int i = 0; i < len; i++){
    cnt += a[i] == b[i];
  }
  return cnt;
}
int main(int argc, char* argv[]) {
  registerTestlibCmd(argc, argv);
  int i = 0, t = inf.readInt();
  m = inf.readInt();
  while(!ans.eof()){
    string qwqwq = inf.readString();
    i++;
    if (i == 1){
      qwqwq = inf.readString();
    }
    string ansa = ans.readString();
    string pa = ouf.readString();
    if (ansa != pa){
      quitp(1.0 * (i - 1) / t, "The output on test %d's check is wrong.", i);
    }
    if (ansa == "No"){
      string ansb = ans.readString();
      string pb = ouf.readString();
      int cnt = qwqwq.size() - change(qwqwq, pb), opop = qwqwq.size() - change(qwqwq, ansb);
      if (ansb.size() != pb.size()){
        quitp(1.0 * (i - 0.5) / t, "The output on test %d's change string's length is diffrant with input string's length.Read string's length is %d,expected string's length is %d.", i, pb.size(), ansb.size());
      }else if (!(checka(pb) || checkb(pb))){
        quitp(1.0 * (i - 0.5) / t, "The output on test %d's change string is wrongful.", i);
      }else if (cnt > opop){
        quitp(0.2, "ok.");//猜测问题在这,改成返回 `_ok` 或 `_wa` 都可以,但返回分数就不行
      }
    }
  }
  quitf(_ok, "The all of output is true.");
}

测试命令:checker.exe in.txt out.txt ans.txt

in.txt 文件:

3 69
o
xn
f

out.txt 文件

Yes
No
aa
Yes

ans.txt 文件

Yes
No
nn
Yes
2022/12/30 10:50
加载中...