| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
这题的Special Judge有错吧试试这个我写的SJ,再看看我的输出。
#include <iostream>
#include <algorithm>
#include <fstream>
#include <cstdlib>
using namespace std;
const char* msgNo1 = "Invalid Number";
int mat[6][6] = {0}, deg[6] = {0};
int ans;
bool mark[6] = {0};
void travel(int v0)
{
mark[v0] = true;
for(int i = 0; i < 6; ++i)
if(!mark[i] && mat[v0][i])
travel(i);
}
ifstream fout;
void err(const char* msg)
{
cout << "Wrong Answer: " << msg << endl;
fout.close();
exit(0);
}
int main(int argc, char* argv[])
{
if(argc != 4)
{
cout << endl << "Usage: check infile outfile ansfile" << endl << endl;
return 0;
}
int i, j, k;
ifstream fans(argv[3]);
fans >> ans;
fans.close();
ifstream fin(argv[1]);
for(fin >> k; k--;)
{
fin >> i >> j;
--i;
--j;
++mat[i][j];
++mat[j][i];
++deg[i];
++deg[j];
}
fin.close();
fout.open(argv[2]);
if(!(fout >> k)) err(msgNo1);
if(k != ans) err("Wrong Total Cost");
if(!(fout >> k)) err(msgNo1);
int sum = 0;
while(k--)
{
if(!(fout >> i >> j)) err(msgNo1);
if(i < 1 || i > 6 || j < 1 || j > 6) err("Domino Number Out of Range");
sum += i + j;
--i;
--j;
++mat[i][j];
++mat[j][i];
++deg[i];
++deg[j];
}
if(sum != ans) err("Total Arc's Cost Not Equals to the Cost You Give");
for(i = 0, j = 0; i < 6; ++i)
j += deg[i] & 1;
if(j > 2) err("No Link Exist, Too Much Odd Points");
for(i = 0; i < 6 && !deg[i]; ++i);
if(i < 6)
{
travel(i);
for(; i < 6 && (!deg[i] || mark[i]); ++i);
}
if(i < 6) err("Graph Not Connected");
char ch;
if(fout >> ch) err("Some More Information after the Output File");
fout.close();
cout << "Accepted!" << endl;
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator