checker:
#define _CRT_SECURE_NO_DEPRECATE
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
FILE *inputfile, *outputfile, *reportfile;
class box
{
public:
int x, y, z;
};
box bs[10000];
int n, m;
class seasdge
{
public:
int x, y, z;
};
seasdge ss[10000000];
int maxans;
class ans
{
public:
int x1, y1, z1, x2, y2, z2, t;
};
ans an[10000000];
int numes[1030][100000];
void checkHave(int i, int j)
{
if (an[i].x2 < an[i].x1 || an[i].y2 < an[i].y1 || an[i].z2 < an[i].z1) {
printf("Format Error.\n");
fprintf(reportfile, "In line %d: The larger number is smaller then the smaller number.", i+2);
exit(2);
}
int xx = an[i].x2-an[i].x1;
int yy = an[i].y2-an[i].y1;
int zz = an[i].z2-an[i].z1;
if (xx > yy)
swap(xx, yy);
if (yy > zz)
swap(yy, zz);
if (xx > yy)
swap(xx, yy);
if (ss[j].x > ss[j].y)
swap(ss[j].x, ss[j].y);
if (ss[j].y > ss[j].z)
swap(ss[j].y, ss[j].z);
if (ss[j].x > ss[j].y)
swap(ss[j].x, ss[j].y);
if (an[i].x1 < 0 || an[i].y1 < 0 || an[i].z1 < 0 || an[i].x2 > bs[an[i].t].x || an[i].y2 > bs[an[i].t].y || an[i].z2 > bs[an[i].t].z) {
printf("Wrong Answer.\n");
fprintf(reportfile, "In line %d: Wrong Position.", i+2);
exit(1);
}
if (xx != ss[j].x || yy != ss[j].y || zz != ss[j].z) {
printf("Wrong Answer.\n");
fprintf(reportfile, "In line %d: Can not find the sea sedge you put.", i+2);
exit(1);
}
}
void against(int i, int j)
{
if (an[j].x1 >= an[i].x1 && an[j].y1 >= an[i].y1 && an[j].z1 >= an[i].z1
&& an[j].x1 < an[i].x2 && an[j].y1 < an[i].y2 && an[j].z1 < an[i].z2) {
printf("Wrong Answer.\n");
fprintf(reportfile, "In line %d: Against with No.%d line of output.", j+2, i+2);
exit(1);
}
if (an[j].x2 > an[i].x1 && an[j].y2 > an[i].y1 && an[j].z2 > an[i].z1
&& an[j].x2 < an[i].x2 && an[j].y2 < an[i].y2 && an[j].z2 < an[i].z2) {
printf("Wrong Answer.\n");
fprintf(reportfile, "In line %d: Against with No.%d line of output.", j+2, i+2);
exit(1);
}
}
void getNumber()
{
for (int j = 0; j < maxans; j++) {
numes[an[j].t][++numes[an[j].t][0]] = j;
}
}
int main(int argc, char **argv)
{
//const char *inputfile = files[1];
//const char *outputfile = files[2];
//const char reportfile[] = "log.txt";
//cout << argv[1] << endl << argv[2] << endl;
if (argc == 3) {
inputfile = fopen(argv[1], "r");
outputfile = fopen(argv[2], "r");
}
if (argc == 2) {
if (argv[1][0] == '1' && argv[1][1] == '0'){
inputfile = /*fopen("seasedge10.in", "r")*/fopen("input10.txt", "r");
outputfile = /*fopen("seasedge10.out", "r")*/fopen("output10.txt", "r");
} else {
char ins[15] = /*"seasedge0.in"*/"input0.txt";
ins[/*8*/5] = argv[1][0];
inputfile = fopen(ins, "r");
char ous[15] = /*"seasedge0.out"*/"output0.txt";
ous[/*8*/6] = argv[1][0];
outputfile = fopen(ous, "r");
}
}
reportfile = fopen("log.txt", "w");
fscanf(inputfile, "%d %d", &n, &m);
for (int i = 1; i <= n; i++) {
fscanf(inputfile, "%d %d %d", &bs[i].x, &bs[i].y, &bs[i].z);
}
for (int i = 1; i <= m; i++) {
fscanf(inputfile, "%d %d %d", &ss[i].x, &ss[i].y, &ss[i].z);
}
fscanf(outputfile, "%d", &maxans);
int x;
for (int i = 0; i < maxans; i++) {
if(fscanf(outputfile, "%d %d %d %d %d %d %d %d", &x, &an[i].t, &an[i].x1, &an[i].y1, &an[i].z1, &an[i].x2, &an[i].y2, &an[i].z2) == EOF) {
fprintf(reportfile, "No enough line.");
printf("Format Error.\n");
exit(2);
}
checkHave(i, x);
}
/*for (int i = 0; i < maxans; i++)
for (int j = i+1; j < maxans; j++)
if (an[i].t == an[j].t) {
against(i, j);
}*/
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= numes[i][0]; j++)
for (int k = j+1; k <= numes[i][0]; k++)
against(numes[i][j], numes[i][k]);
}
printf("Correct! Your answer is %d.\n", maxans);
return 0;
}
数据生成器:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
using namespace std;
class box
{
public:
int t;
int x0, y0, z0;
int x, y, z;
box(int x0 = 0, int y0 = 0, int z0 = 0):x0(x0), y0(y0), z0(z0) {}
};
box bo[1000000];
box ans[1000000];
int at;
void swap(box &a, box &b)
{
box t = a;
a = b;
b = t;
}
int main()
{
srand(time(0));
char infile[15] = "input1.txt"/*"seasedge1.in"*/;
char outfile[15] = "output1.out"/*"seasedge1.out"*/;
char spjfile[15] = "output1.txt"/*"seasedge1.ans"*/;
for (int i = 1; i <= 9; i++, infile[/*8*/5]++, outfile[/*8*/6]++, spjfile[/*8*/6]++) {
FILE *input = fopen(infile, "w");
FILE *output = fopen(outfile, "w");
FILE *spj = fopen(spjfile, "w");
int n = (int)pow(2, i);
at = 0;
int m = (int)pow(3, i+1);
for (int j = 1; j <= n; j++) {
bo[j].x = rand()%(int)pow(4, i)+1;
bo[j].y = rand()%(int)pow(4, i)+1;
bo[j].z = rand()%(int)pow(4, i)+1;
bo[j].t = j;
bo[j].x0 = bo[j].y0 = bo[j].z0 = 0;
}
for (int j = 1; j <= n; j++)
if (bo[j].x < 10) {
bo[1].x =bo[1].y = bo[1].z = 10;
}
int l = 1, r = n;
int xx, yy, zz;
while (r-l < m && l <= r) {
xx = bo[l].x;
yy = bo[l].y;
zz = bo[l].z;
if (xx == 1 || yy == 1 || zz == 1) {
l++;
ans[++at] = bo[l-1];
continue;
}
xx = rand()%(xx-1) + 1;
yy = rand()%(yy-1) + 1;
zz = rand()%(zz-1) + 1;
bo[++r].x = xx;
bo[r].y = yy;
bo[r].z = zz;
bo[r].x0 = bo[l].x0;
bo[r].y0 = bo[l].y0;
bo[r].z0 = bo[l].z0;
bo[r].t = bo[l].t;
bo[++r].x = bo[l].x-xx;
bo[r].y = bo[l].y-yy;
bo[r].z = bo[l].z-zz;
bo[r].x0 = bo[l].x0+xx;
bo[r].y0 = bo[l].y0+yy;
bo[r].z0 = bo[l].z0+zz;
bo[r].t = bo[l].t;
l++;
}
m = r-l+1;
fprintf(input, "%d %d\n", n, at+m);
for (int j = 1; j <= n; j++) {
fprintf(input, "%d %d %d\n", bo[j].x, bo[j].y, bo[j].z);
}
for (int j = 1; j <= m; j++) {
int x = rand()%m;
int y = rand()%m;
swap(bo[l+x], bo[l+y]);
}
for (int j = 1; j <= at; j++) {
int x = rand()%at;
int y = rand()%at;
swap(ans[x+1], ans[y+1]);
}
fprintf(output, "%d\n", at+m);
for (int j = 1; j <= at; j++) {
fprintf(input, "%d %d %d\n", ans[j].x, ans[j].y, ans[j].z);
fprintf(output, "%d %d %d %d %d %d %d %d\n", j, ans[j].t, ans[j].x0, ans[j].y0, ans[j].z0, ans[j].x0+ans[j].x, ans[j].y0+ans[j].y, ans[j].z0+ans[j].z);
}
for (int j = l; j <= r; j++) {
fprintf(input, "%d %d %d\n", bo[j].x, bo[j].y, bo[j].z);
fprintf(output, "%d %d %d %d %d %d %d %d\n", j-l+1+at, bo[j].t, bo[j].x0, bo[j].y0, bo[j].z0, bo[j].x0+bo[j].x, bo[j].y0+bo[j].y, bo[j].z0+bo[j].z);
}
for (int j = 5; j >= 1; j--) {
fprintf(spj, "%d\n", (at+m)*(j+5)/10);
}
}
int i = 10;
FILE *input = fopen("input10.txt", "w")/*fopen("seasedge10.in", "w")*/;
FILE *output = fopen("output10.out", "w");/*fopen("seasedge10.out", "w")*/;
FILE *spj = fopen("output10.txt", "w");/*fopen("seasedge10.ans", "w")*/;
int n = (int)pow(2, i);
at = 0;
int m = (int)pow(3, i+1);
for (int j = 1; j <= n; j++) {
bo[j].x = rand()%(int)pow(4, i)+1;
bo[j].y = rand()%(int)pow(4, i)+1;
bo[j].z = rand()%(int)pow(4, i)+1;
bo[j].t = j;
bo[j].x0 = bo[j].y0 = bo[j].z0 = 0;
}
if (i == 1) {
bo[1].x =bo[1].y = bo[1].z = 10;
}
int l = 1, r = n;
int xx, yy, zz;
while (r-l+at < m && l <= r) {
xx = bo[l].x;
yy = bo[l].y;
zz = bo[l].z;
if (xx == 1 || yy == 1 || zz == 1) {
l++;
ans[++at] = bo[l-1];
continue;
}
xx = rand()%(xx-1) + 1;
yy = rand()%(yy-1) + 1;
zz = rand()%(zz-1) + 1;
bo[++r].x = xx;
bo[r].y = yy;
bo[r].z = zz;
bo[r].x0 = bo[l].x0;
bo[r].y0 = bo[l].y0;
bo[r].z0 = bo[l].z0;
bo[r].t = bo[l].t;
bo[++r].x = bo[l].x-xx;
bo[r].y = bo[l].y-yy;
bo[r].z = bo[l].z-zz;
bo[r].x0 = bo[l].x0+xx;
bo[r].y0 = bo[l].y0+yy;
bo[r].z0 = bo[l].z0+zz;
bo[r].t = bo[l].t;
l++;
}
m = r-l+1;
fprintf(input, "%d %d\n", n, at+m);
for (int j = 1; j <= n; j++) {
fprintf(input, "%d %d %d\n", bo[j].x, bo[j].y, bo[j].z);
}
/*for (int j = 1; j <= m; j++) {
int x = rand()%m;
int y = rand()%m;
swap(bo[l+x], bo[l+y]);
}*/
fprintf(output, "%d\n", at+m);
for (int j = 1; j <= at; j++) {
fprintf(input, "%d %d %d\n", ans[j].x, ans[j].y, ans[j].z);
fprintf(output, "%d %d %d %d %d %d %d %d\n", j, ans[j].t, ans[j].x0, ans[j].y0, ans[j].z0, ans[j].x0+ans[j].x, ans[j].y0+ans[j].y, ans[j].z0+ans[j].z);
}
for (int j = l; j <= r; j++) {
fprintf(input, "%d %d %d\n", bo[j].x, bo[j].y, bo[j].z);
fprintf(output, "%d %d %d %d %d %d %d %d\n", j-l+1+at, bo[j].t, bo[j].x0, bo[j].y0, bo[j].z0, bo[j].x0+bo[j].x, bo[j].y0+bo[j].y, bo[j].z0+bo[j].z);
}
for (int j = 5; j >= 1; j--) {
fprintf(spj, "%d\n", (at+m)*(j+5)/10);
}
return 0;
}
SPJ:
#define _CRT_SECURE_NO_DEPRECATE
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
FILE *inputfile, *outputfile, *reportfile, *standfile;
class box
{
public:
int x, y, z;
};
box bs[10000];
int n, m;
class seasdge
{
public:
int x, y, z;
};
seasdge ss[10000000];
int maxans;
class ans
{
public:
int x1, y1, z1, x2, y2, z2, t;
};
ans an[10000000];
int numes[1030][100000];
void checkHave(int i, int j)
{
if (an[i].x2 < an[i].x1 || an[i].y2 < an[i].y1 || an[i].z2 < an[i].z1) {
printf("Format Error.\n");
fprintf(reportfile, "In line %d: The larger number is smaller then the smaller number.", i+2);
exit(2);
}
int xx = an[i].x2-an[i].x1;
int yy = an[i].y2-an[i].y1;
int zz = an[i].z2-an[i].z1;
if (xx > yy)
swap(xx, yy);
if (yy > zz)
swap(yy, zz);
if (xx > yy)
swap(xx, yy);
if (ss[j].x > ss[j].y)
swap(ss[j].x, ss[j].y);
if (ss[j].y > ss[j].z)
swap(ss[j].y, ss[j].z);
if (ss[j].x > ss[j].y)
swap(ss[j].x, ss[j].y);
if (an[i].x1 < 0 || an[i].y1 < 0 || an[i].z1 < 0 || an[i].x2 > bs[an[i].t].x || an[i].y2 > bs[an[i].t].y || an[i].z2 > bs[an[i].t].z) {
fprintf(reportfile, "0.0");
exit(0);
}
if (xx != ss[j].x || yy != ss[j].y || zz != ss[j].z) {
fprintf(reportfile, "0.0");
exit(0);
}
}
void against(int i, int j)
{
if (an[j].x1 >= an[i].x1 && an[j].y1 >= an[i].y1 && an[j].z1 >= an[i].z1
&& an[j].x1 < an[i].x2 && an[j].y1 < an[i].y2 && an[j].z1 < an[i].z2) {
fprintf(reportfile, "0.0");
exit(0);
}
if (an[j].x2 > an[i].x1 && an[j].y2 > an[i].y1 && an[j].z2 > an[i].z1
&& an[j].x2 < an[i].x2 && an[j].y2 < an[i].y2 && an[j].z2 < an[i].z2) {
fprintf(reportfile, "0.0");
exit(0);
}
}
void getNumber()
{
for (int j = 0; j < maxans; j++) {
numes[an[j].t][++numes[an[j].t][0]] = j;
}
}
int main(int argc, char **argv)
{
inputfile = fopen(argv[1], "r");
outputfile = fopen(argv[2], "r");
standfile = fopen(argv[3], "r");
reportfile = fopen(argv[4], "w");
fscanf(inputfile, "%d %d", &n, &m);
for (int i = 1; i <= n; i++) {
fscanf(inputfile, "%d %d %d", &bs[i].x, &bs[i].y, &bs[i].z);
}
for (int i = 1; i <= m; i++) {
fscanf(inputfile, "%d %d %d", &ss[i].x, &ss[i].y, &ss[i].z);
}
fscanf(outputfile, "%d", &maxans);
int x;
for (int i = 0; i < maxans; i++) {
if(fscanf(outputfile, "%d %d %d %d %d %d %d %d", &x, &an[i].t, &an[i].x1, &an[i].y1, &an[i].z1, &an[i].x2, &an[i].y2, &an[i].z2) == EOF) {
fprintf(reportfile, "0.0");
exit(0);
}
checkHave(i, x);
}
/*for (int i = 0; i < maxans; i++)
for (int j = i+1; j < maxans; j++)
if (an[i].t == an[j].t) {
against(i, j);
}*/
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= numes[i][0]; j++)
for (int k = j+1; k <= numes[i][0]; k++)
against(numes[i][j], numes[i][k]);
}
int c[10];
for (int i = 1; i <= 5; i++)
fscanf(standfile, "%d", &c[i]);
if (maxans > c[1]) {
fprintf(reportfile, "1.2");
exit(0);
}
if (maxans == c[1]) {
fprintf(reportfile, "1.0");
exit(0);
}
if (maxans >= c[2]) {
fprintf(reportfile, "0.9");
exit(0);
}
if (maxans >= c[3]) {
fprintf(reportfile, "0.8");
exit(0);
}
if (maxans >= c[4]) {
fprintf(reportfile, "0.6");
exit(0);
}
if (maxans >= c[5]) {
fprintf(reportfile, "0.4");
exit(0);
}
fprintf(reportfile, "0.2");
return 0;
}
标准输出:
http://yunpan.cn/cjXZ2iyDISgzd (提取码:0502)
这道题目由于OJ上有提交答案的文件大小限制,所以数据规模实际上是改小了的,有兴趣的同学可以自己用数据生成器改数据规模