Artifact 735a19ded3f1e4b90c5a5ecc988527f491acf236
#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>
using namespace std;
typedef long long LL;
typedef long double LD;
typedef complex<LD> CMP;
class RobotHerb { public:
long long getdist(int T, vector <int> a)
{
static const LL dx[] = {+1,0,-1,0};
static const LL dy[] = {0,+1,0,-1};
LL x=0, y=0, d=0, xs[5]={}, ys[5]={};
for(int i=0; i<4; ++i)
{
for(int k=0; k<a.size(); ++k)
{
x += dx[d%4] * a[k];
y += dy[d%4] * a[k];
d += a[k];
}
xs[i+1] = x;
ys[i+1] = y;
}
x = (xs[4]-xs[0])*(T/4) + xs[T%4];
y = (ys[4]-ys[0])*(T/4) + ys[T%4];
return abs(x)+abs(y);
}
};
// 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 long long& Expected, const long long& 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(_, RobotHerb().getdist(T, a));}
int main(){
CASE(0)
int T = 1;
int a_[] = {1,2,3};
vector <int> a(a_, a_+sizeof(a_)/sizeof(*a_));
long long _ = 2LL;
END
CASE(1)
int T = 100;
int a_[] = {1};
vector <int> a(a_, a_+sizeof(a_)/sizeof(*a_));
long long _ = 0LL;
END
CASE(2)
int T = 5;
int a_[] = {1,1,2};
vector <int> a(a_, a_+sizeof(a_)/sizeof(*a_));
long long _ = 10LL;
END
CASE(3)
int T = 1000000000;
int a_[] = {100};
vector <int> a(a_, a_+sizeof(a_)/sizeof(*a_));
long long _ = 100000000000LL;
END
CASE(4)
int T = 570;
int a_[] = {2013,2,13,314,271,1414,1732};
vector <int> a(a_, a_+sizeof(a_)/sizeof(*a_));
long long _ = 4112LL;
END
/*
CASE(5)
int T = ;
int a_[] = ;
vector <int> a(a_, a_+sizeof(a_)/sizeof(*a_));
long long _ = LL;
END
CASE(6)
int T = ;
int a_[] = ;
vector <int> a(a_, a_+sizeof(a_)/sizeof(*a_));
long long _ = LL;
END
*/
}
// END CUT HERE