Jeanny
寂兮,寥兮,独立不改,周行而不殆

sdfzoj/problem/758 千帆渡

lemon_spj

argv[1]:输入文件

argv[2]:选手输出文件

argv[3]:标准输出文件

argv[4]:单个测试点分值

argv[5]:输出最终得分的文件

argv[6]:输出错误报告的文件

#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
int k[N], a[N], b[N];
int main(int argc, char *argv[]) {
    FILE *fin = fopen(argv[1], "r");
    FILE *fout = fopen(argv[2], "r");
    FILE *ans = fopen(argv[3], "r");
    FILE *score = fopen(argv[5], "w");
    FILE *msg = fopen(argv[6], "w");
    int your, std, i, x, y, n, m;
    fscanf(fout, "%d", &your);
    for (i = 1; i <= your; ++i) fscanf(fout, "%d", &k[i]);
    for (i = 2; i <= your; ++i)
        if (k[i - 1] > k[i]) {
            fprintf(score, "0\n");
            fprintf(msg, "Sequence is not increasing.\n");
            return 0;
        }
    fscanf(ans, "%d", &std);
    if (your != std) {
        fprintf(score, "0\n");
        fprintf(msg, "WA on the first line and skipped.\n");
        return 0;
    }
    fscanf(fin, "%d", &n);
    for (i = 1; i <= n; ++i) fscanf(fin, "%d", &a[i]);
    fscanf(fin, "%d", &m);
    for (i = 1; i <= m; ++i) fscanf(fin, "%d", &b[i]);
    for (i = x = y = 1; i <= your && x <= n && y <= m; ++i) {
        while (x <= n && a[x] != k[i]) ++x;
        while (y <= m && b[y] != k[i]) ++y; 
    }
    if (i == your + 1 && x <= n && y <= m) {
        fprintf(score, "%s\n", argv[4]);
        fprintf(msg, "A feasible solution!\n");
        return 0;
    } else {
        fprintf(score, "0\n");
        fprintf(msg, "WA on the second line.\n");
        return 0;
    }
}

luogu_spj
inf 指数据输入文件(本例没有),ouf 指选手输出文件,ans 指标准答案。
int readInt()
https://www.luogu.com.cn/blog/luogu/special-judge

#include <bits/stdc++.h>
#include "testlib.h"
using namespace std;
const int N = 5005;
int k[N], a[N], b[N];
int main(int argc, char *argv[]) {
	registerTestlibCmd(argc, argv);
	int your, std, i, x, y, n, m;
	your = ouf.readInt();
	for (i = 1; i <= your; ++i) k[i] = ouf.readInt();
	for (i = 2; i <= your; ++i)
		if (k[i - 1] > k[i]) {
			quitf(_wa, "Sequence is not increasing.\n");
			return 0;
		}
	std = ans.readInt();
	if (your != std) {
		quitf(_wa, "WA on the first line and skipped.\n");
		return 0;
	}
	n = inf.readInt();
	for (i = 1; i <= n; ++i) a[i] = inf.readInt();
	m = inf.readInt();
	for (i = 1; i <= m; ++i) b[i] = inf.readInt();
	for (i = x = y = 1; i <= your && x <= n && y <= m; ++i) {
		while (x <= n && a[x] != k[i]) ++x;
		while (y <= m && b[y] != k[i]) ++y; 
	}
	if (i == your + 1 && x <= n && y <= m) {
		quitf(_ok, "A feasible solution!\n");
	} else {
		quitf(_wa, "WA on the second line.\n");
	}
	return 0;
}

最后将名字改为spj_cpp.cpp放到数据包里,压缩

Native - DP II(http://sdfzoj.zhaojinxi.top/problem/896)

#include <bits/stdc++.h>
#include "testlib.h"
using namespace std;
int x[5010], y[5010];
string str;

#define w(_a, _b) ((x[_a] + y[_b]) % Mod)

void Judge(){
     int Ans, Usr;
     Ans = ans.readInt();
     Usr = ouf.readInt();
     if (Usr != Ans){
          quitf(_wa,  "0 你在逗我吗!都不对。\n");
          return;
     }
     int n, m, Mod;
     n = inf.readInt();
     m = inf.readInt();
     Mod = inf.readInt();
     for (int i = 1; i <= n; ++i){
         x[i] = inf.readInt();
     }
     for (int i = 1; i <= m; ++i){
         y[i] = inf.readInt();
     }
     str = ouf.readString();
     cerr<<"|||| "<<str<<endl;
     str = ouf.readString();
     cerr<<"XXXX "<<str<<endl;
     int nowx = 1, nowy = 1;
     int now = w(1, 1);
     for (int i = 0; i<str.length(); ++i){
          if (str[i] == 'P') ++nowx;
          if (str[i] == 'T') ++nowy;
          cerr<<nowx<<" "<<nowy<<endl;
          if (nowx <= n && nowy <= m){
              now += w(nowx, nowy);
          } else{
               quitf(_wa,"0 你的小W失踪啦?我并没有看到他。\n");
               return;
          }
     }
     cerr<<now<<" "<<Ans<<endl;
     if (now == Ans){
          quitf(_ok,"1 恭喜你AC啦Orz");
     } else{
          quitf(_wa,"0 你不太对啊");
     }
}

int main (int argc, char* argv[]){
    registerTestlibCmd(argc, argv);
    Judge();
    return 0;
}

posted on 2022-02-10 10:21  Jeanny  阅读(349)  评论(0)    收藏  举报