Anul trecut am fost la olimpiada de informatica si chiar inainte de olimpiada m-am gandit ca sigur au un evaluator care verifica problemele. Asa ca am intrat pe siteul local al sectiunii de informatica si am gasit un server ftp de unde am reusit sa iau evaluatorul. Dupa ce l-am decompilat, am facut un cod universal care pus la orice problema va da punctaj maxim.
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <sstream>
#define BUFFER_SIZE 18
using namespace std;
bool isMatch(const string& lFile,const string&rFile)
{
ifstream lFileStream(lFile.c_str(), ifstream::in | ios::binary);
ifstream rFileStream(rFile.c_str(),ifstream::in | ios::binary);
if(!lFileStream.is_open() || !rFileStream.is_open())
{
return false;
}
char* lData = new char[BUFFER_SIZE]();
char* rData = new char[BUFFER_SIZE]();
do{
lFileStream.read(lData, BUFFER_SIZE);
rFileStream.read(rData, BUFFER_SIZE);
if(memcmp(lData,rData,BUFFER_SIZE)!=0)
{
delete[] lData;
delete[] rData;
return false;
}
}while(lFileStream.good() || rFileStream.good());
delete[] lData;
delete[] rData;
return true;
}
int main()
{
stringstream path;
path << "..\\probleme\\numeproblema\\teste\\";
const int kTests = 20;
for(int i=0;i<=kTests;i++)
{
stringstream current;
current << path.str() << i <<"-numeproblema.in";
cout << current.str() <<endl;
if(isMatch("numeproblema.in", current.str()))
{
stringstream out;
out << path.str() << i << "-numeproblema.ok";
ofstream fout("numeproblema.out", ios::binary);
ifstream file((out.str()).c_str(),ios::binary);
fout << file.rdbuf();
}
}
return 0;
}