Judge:Help/check.cpp

From PEGWiki
Revision as of 00:32, 19 October 2011 by Brian (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

In the code below, F is the correct output for this test case, and G is your output.

#include <iostream>
#include <sstream>
#include <fstream>
#include <vector>
 
using namespace std;
 
vector<string> split(string& s)
{
        vector<string> vs;
        istringstream sin(s);
        while (sin >> s)
                vs.push_back(s); return vs;
}
 
bool Getline(ifstream& f, vector<string>& s)
{
        while (s.empty())
        {
                string str;
                if (!getline(f, str)) return false;
                s = split(str);
        }
        return true;
}
 
int main(int argv, char ** argc)
{
        ifstream F(argc[1]);
        ifstream G(argc[2]);
        bool a, b;
        vector<string> s, t;
        do
        {
                s = vector<string>();
                t = s;
                a = Getline(F, s);
                b = Getline(G, t);
                if (a ^ b) return 1;
                if (a && b && s != t) return 1;
        }
        while (a && b);
 
        return 0;
}