spj
作者:互联网
sdfzoj/problem/758 千帆渡
lemon_spj
https://www.cnblogs.com/arcturus/p/9501345.html
#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
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放到数据包里,压缩
标签:std,int,argv,spj,FILE,fopen,your 来源: https://www.cnblogs.com/caterpillor/p/15878025.html