Artifact 905f678193eee983995c4426eae4eb2c6da0beb3
#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 <tuple>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;
class VampireTree { public:
int maxDistance(vector <int> num)
{
int d1 = 0, d_else = 0, d_kill = 0;
for(int d: num)
if(d == 1)
d1++;
else
d_else++, d_kill+=d-2;
if(d1-d_kill == 2)
return d_else + 1;
else
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(_, VampireTree().maxDistance(num));}
int main(){
CASE(0)
int num_[] = {1, 2, 1};
vector <int> num(num_, num_+sizeof(num_)/sizeof(*num_));
int _ = 2;
END
CASE(1)
int num_[] = {2, 2, 2};
vector <int> num(num_, num_+sizeof(num_)/sizeof(*num_));
int _ = -1;
END
CASE(2)
int num_[] = {1, 1, 1, 1, 4};
vector <int> num(num_, num_+sizeof(num_)/sizeof(*num_));
int _ = 2;
END
CASE(3)
int num_[] = {1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
vector <int> num(num_, num_+sizeof(num_)/sizeof(*num_));
int _ = -1;
END
/*
CASE(4)
int num_[] = ;
vector <int> num(num_, num_+sizeof(num_)/sizeof(*num_));
int _ = ;
END
CASE(5)
int num_[] = ;
vector <int> num(num_, num_+sizeof(num_)/sizeof(*num_));
int _ = ;
END
*/
}
// END CUT HERE