有更详细的报错
#include <bits/stdc++.h>
#include <windows.h>
using namespace std;
ifstream fin;
ofstream fout;
int n, m, times;
int zhu[550][5000];
int top[550]; //每个柱子顶部的位置
bool flag[1100];
void move_(int x, int y) {
top[y]++;
zhu[y][top[y]] = zhu[x][top[x]];
zhu[x][top[x]]=0;
top[x]--;
}
int main() {
fout.open("P7115-checker-运行结果.txt");
cout << "请输入 题目输入 的文件名(要带文件后缀)\n";
char file1[114514]; //输入
cin >> file1;
cout << "请输入 选手输出 的文件名(要带文件后缀)\n";
char file2[114514]; //选手输出
cin >> file2;
fin.open(file1);
if (!fin) {
fout << "打开 题目输入 文件失败,请检查输入文件是否存在\n";
cout << "打开 题目输入 文件失败,请检查输入文件是否存在\n";
system("pause");
}
fin >> n >> m;
for (int w = 1; w <= n; w++) {
top[w] = m;
for (int ww = 1; ww <= m; ww++) {
fin >> zhu[w][ww];
}
}
fin.close();
fin.open(file2);
if (!fin) {
fout << "打开 选手输出 文件失败,请检查 选手输出 是否存在\n";
cout << "打开 选手输出 文件失败,请检查 选手输出 是否存在\n";
system("pause");
}
fin >> times;
cout << times << "\n";
if(times>820000) {
MessageBox(NULL, "步数超限\n", "WA", MB_OK);
cout<<"步数超限\n";
fout<<"步数超限\n";
}
int a, b;
bool wsw = 1;
for (int yy = 1; yy <= times; yy++) {
fin >> a >> b;
if (top[a] == 0) {
fout << "操作 " << yy << " ";
fout << "在从 " << a << " 移动到" << b << " 时 " << a << " 为 空!\n";
cout << "操作 " << yy << " ";
cout << "在从 " << a << " 移动到" << b << " 时 " << a << " 为 空!\n";
wsw = 0;
} else if (top[b] >= m) {
fout << "操作 " << yy << " ";
fout << "在从 " << a << " 移动到" << b << " 时 " << b << " 溢出\n";
cout << "操作 " << yy << " ";
cout << "在从 " << a << " 移动到" << b << " 时 " << b << " 溢出\n";
wsw = 0;
}
move_(a, b);
}
int cnt_=0,pla;
for (int ww = 1; ww <= n+1; ww++) {
if(top[ww]==0) {
cnt_++;
continue;
}
if (top[ww] != m) {
fout << ww << " 中的数量不足!\n";
cout << ww << " 中的数量不足!\n";
wsw = 0;
}
}
if(cnt_>1) {
cout<<"有球被吞了\n";
fout<<"有球被吞了\n";
}
int tmp;
for (int rr = 1; rr <= n+1; rr++) {
for (int ww = 1; ww <= m; ww++) {
if (zhu[rr][ww] != zhu[rr][1]) {
fout << "第 " << rr << " 号柱子上有颜色不同的球\n";
cout << "第 " << rr << " 号柱子上有颜色不同的球\n";
wsw = 0;
break;
}
}
}
if (wsw) {
MessageBox(NULL, "AC\n", "AC", MB_OK);
fout << "AC\n";
cout << "AC\n";
}
fout << endl<< "\n";
cout << endl<< "\n";
fout << "你的程序的最终操作结果为:\n";
cout << "你的程序的最终操作结果为:\n";
for (int rr = 1; rr <= n+1; rr++) {
// tmp = zhu[rr][1];
for (int ww = 1; ww <= m; ww++) {
fout << zhu[rr][ww] << " ";
cout << zhu[rr][ww] << " ";
}
fout << "\n";
cout << "\n";
}
MessageBox(NULL, "checker运行结果已保存在文件中\n", "SPJ", MB_OK);
}