Artifact Content
Not logged in

Artifact b72e6c307321202592aa4327e35047892cae9ada


#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <functional>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <cstring>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;

class ToastXToast { public:
	int bake(vector <int> undertoasted, vector <int> overtoasted) 
	{
		vector< pair<int,bool> > t_o;
		for(int i=0; i<undertoasted.size(); ++i)
			t_o.push_back( make_pair(undertoasted[i], false) );
		for(int i=0; i<overtoasted.size(); ++i)
			t_o.push_back( make_pair(overtoasted[i], true) );
		sort(t_o.begin(), t_o.end());

		vector<bool> o;
		for(int i=0; i<t_o.size(); ++i)
			o.push_back( t_o[i].second );

		if( o.front() || !o.back() )
			return -1;
		for(int i=0; i+1<o.size(); ++i)
			if( o[i] && !o[i+1] )
				return 2;
		return 1;
	}
};

// BEGIN CUT HERE
#include <ctime>
double start_time; string timer()
 { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
 { os << "{ ";
   for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
   os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; }
void verify_case(const int& Expected, const int& Received) {
 bool ok = (Expected == Received);
 if(ok) cerr << "PASSED" << timer() << endl;  else { cerr << "FAILED" << timer() << endl;
 cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } }
#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock();
#define END	 verify_case(_, ToastXToast().bake(undertoasted, overtoasted));}
int main(){

CASE(0)
	int undertoasted_[] = {2,4};
	  vector <int> undertoasted(undertoasted_, undertoasted_+sizeof(undertoasted_)/sizeof(*undertoasted_)); 
	int overtoasted_[] = {5,6,3};
	  vector <int> overtoasted(overtoasted_, overtoasted_+sizeof(overtoasted_)/sizeof(*overtoasted_)); 
	int _ = 2; 
END
CASE(1)
	int undertoasted_[] = {5};
	  vector <int> undertoasted(undertoasted_, undertoasted_+sizeof(undertoasted_)/sizeof(*undertoasted_)); 
	int overtoasted_[] = {4};
	  vector <int> overtoasted(overtoasted_, overtoasted_+sizeof(overtoasted_)/sizeof(*overtoasted_)); 
	int _ = -1; 
END
CASE(2)
	int undertoasted_[] = {1,2,3};
	  vector <int> undertoasted(undertoasted_, undertoasted_+sizeof(undertoasted_)/sizeof(*undertoasted_)); 
	int overtoasted_[] = {5,6,7};
	  vector <int> overtoasted(overtoasted_, overtoasted_+sizeof(overtoasted_)/sizeof(*overtoasted_)); 
	int _ = 1; 
END
CASE(3)
	int undertoasted_[] = {1,3,5};
	  vector <int> undertoasted(undertoasted_, undertoasted_+sizeof(undertoasted_)/sizeof(*undertoasted_)); 
	int overtoasted_[] = {2,4,6};
	  vector <int> overtoasted(overtoasted_, overtoasted_+sizeof(overtoasted_)/sizeof(*overtoasted_)); 
	int _ = 2; 
END
/*
CASE(4)
	int undertoasted_[] = ;
	  vector <int> undertoasted(undertoasted_, undertoasted_+sizeof(undertoasted_)/sizeof(*undertoasted_)); 
	int overtoasted_[] = ;
	  vector <int> overtoasted(overtoasted_, overtoasted_+sizeof(overtoasted_)/sizeof(*overtoasted_)); 
	int _ = ; 
END
CASE(5)
	int undertoasted_[] = ;
	  vector <int> undertoasted(undertoasted_, undertoasted_+sizeof(undertoasted_)/sizeof(*undertoasted_)); 
	int overtoasted_[] = ;
	  vector <int> overtoasted(overtoasted_, overtoasted_+sizeof(overtoasted_)/sizeof(*overtoasted_)); 
	int _ = ; 
END
*/
}
// END CUT HERE