shi-yang / jnoj

Jiangnan Online Judge
https://www.jnoj.dev
Other
241 stars 62 forks source link

OJ中的Special Judge无法得到正确的答案 #9

Closed nihongsama closed 5 years ago

nihongsama commented 5 years ago

经过尝试,发现现在的oj上的special judge功能貌似无法正常工作。 首先,现在我的jnoj是在centos 7系统下进行配置的,除了special judge外,判题一切正常。 我将某个基于hustoj搭建的oj上能够正常工作的spj加入到jnoj中,却发现jnoj会直接返回wrong answer 更有甚者,我将jnoj所展示的标准spj代码进行了如下修改后:

#include <bits/stdc++.h>
using namespace std;
#define AC 0
#define WA 1
#define ERROR -1

int spj(FILE *input, FILE *user_output){
    /*
      parameter:
        - input,your input file pointer
        - user_output,user output file pointer
      return:
        - if the answer is correct, return AC else return WA
        - if something unexpected happened in your judge function, you can return ERROR

      demo:
*/
      int a, b;
      while(fscanf(user_output, "%d %d", &a, &b) != EOF){
          if(a -b != 3){
              return WA;
          }
      }
      return AC;
}

void close_file(FILE *f){
    if(f != NULL){
        fclose(f);
    }
}

int main(int argc, char *args[]){
    FILE *input = NULL, *user_output = NULL;
    int result;
    if(argc != 4){
        printf("Usage: spj x.in x.out\n");
        return ERROR;
    }
    input = fopen(args[1], "r");
    user_output = fopen(args[2], "r");
    if(input == NULL || user_output == NULL){
        printf("Failed to open output file\n");
        close_file(input);
        close_file(user_output);
        return ERROR;
    }

    result = spj(input, user_output);
    printf("result: %d\n", result);

    close_file(input);
    close_file(user_output);
    return result;
} 

后用代码:

#include <bits/stdc++.h>
using namespace std;
int main()
{
    cout<<3<<" "<<0<<endl;
    return 0;
}

提交后发现仍然返回wrong answer。 我个人安装均按照了教程指引,现在请问一下是因为我的机子编译器的问题还是原本的spj的配置有有些漏洞呢?

shi-yang commented 5 years ago

嗯,感谢报告。已定位该问题,是因为spj没可执行权限的原因