Artifact a3074f7b005ac1af7f73d2859eb9a9e783915ee3
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <cstring>
using namespace std;
typedef long long LL;
int to_i(const string& s) {
int n;
stringstream(s)>>n;
return n;
}
class BirthNumbersValidator {
public:
vector <string> validate(vector <string> test)
{
vector<string> ans;
transform(test.begin(), test.end(), back_inserter(ans), &testeach);
return ans;
}
static string testeach( const string& x )
{
int y = to_i(x.substr(0,2));
int m = to_i(x.substr(2,2));
int d = to_i(x.substr(4,2));
if( 1<=m && m<=12 ) {}
else if( 51<=m && m<=62 ) { m-=50; }
else return "NO";
bool leap = (y%4)==0;
int dd[] = {31, leap?29:28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
if( 1<=d && d<=dd[m-1] ) {}
else return "NO";
LL cd; stringstream(x)>>cd;
return cd%11==0 ? "YES" : "NO";
}
};
// 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> string print_array(const vector<T> &V) { ostringstream os; os << "{ "; for (typename vector<T>::const_iterator iter = V.begin(); iter != V.end(); ++iter) os << '\"' << *iter << "\","; os << " }"; return os.str(); }
int verify_case(const vector <string> &Expected, const vector <string> &Received) { if (Expected == Received) cerr << "PASSED" << timer() << endl; else { cerr << "FAILED" << timer() << endl; cerr << "\tExpected: " << print_array(Expected) << endl; cerr << "\tReceived: " << print_array(Received) << endl; } return 0;}
template<int N> struct Case_ { Case_(){start_time=clock();} };
char Test_(...);
int Test_(Case_<0>) {
string test_[] = {"8104121234"};
vector <string> test(test_, test_+sizeof(test_)/sizeof(*test_));
string RetVal_[] = {"YES" };
vector <string> RetVal(RetVal_, RetVal_+sizeof(RetVal_)/sizeof(*RetVal_));
return verify_case(RetVal, BirthNumbersValidator().validate(test)); }
int Test_(Case_<1>) {
string test_[] = {"8154121239"};
vector <string> test(test_, test_+sizeof(test_)/sizeof(*test_));
string RetVal_[] = {"YES" };
vector <string> RetVal(RetVal_, RetVal_+sizeof(RetVal_)/sizeof(*RetVal_));
return verify_case(RetVal, BirthNumbersValidator().validate(test)); }
int Test_(Case_<2>) {
string test_[] = {"8134120005"};
vector <string> test(test_, test_+sizeof(test_)/sizeof(*test_));
string RetVal_[] = {"NO" };
vector <string> RetVal(RetVal_, RetVal_+sizeof(RetVal_)/sizeof(*RetVal_));
return verify_case(RetVal, BirthNumbersValidator().validate(test)); }
int Test_(Case_<3>) {
string test_[] = {"8102310007","8104121235"};
vector <string> test(test_, test_+sizeof(test_)/sizeof(*test_));
string RetVal_[] = {"NO", "NO" };
vector <string> RetVal(RetVal_, RetVal_+sizeof(RetVal_)/sizeof(*RetVal_));
return verify_case(RetVal, BirthNumbersValidator().validate(test)); }
int Test_(Case_<4>) {
string test_[] = {"0411131237"};
vector <string> test(test_, test_+sizeof(test_)/sizeof(*test_));
string RetVal_[] = {"YES" };
vector <string> RetVal(RetVal_, RetVal_+sizeof(RetVal_)/sizeof(*RetVal_));
return verify_case(RetVal, BirthNumbersValidator().validate(test)); }
template<int N> void Run_() { cerr << "Test Case #" << N << "..." << flush; Test_(Case_<N>()); Run_<sizeof(Test_(Case_<N+1>()))==1 ? -1 : N+1>(); }
template<> void Run_<-1>() {}
int main() { Run_<0>(); }
// END CUT HERE