Difference between revisions of "Judge:Help/check.cpp"

From PEGWiki
Jump to: navigation, search
(Created page with "<syntaxhighlight lang="cpp> #include <iostream> #include <sstream> #include <fstream> #include <vector> using namespace std; vector<string> split(string& s) { vector<st...")
 
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
<syntaxhighlight lang="cpp>
+
In the code below, <code>F</code> is the correct output for this test case, and <code>G</code> is your output.
 +
 
 +
<syntaxhighlight lang="cpp">
 
#include <iostream>
 
#include <iostream>
 
#include <sstream>
 
#include <sstream>

Latest revision as of 00:32, 19 October 2011

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;
}