Artifact Content
Not logged in

Artifact 11f187ebddae9d97b7abcc477d30c430ea810694


#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 CrouchingAmoebas { public:
	int count(vector <int> x, vector <int> y, int A, int T) 
	{
		int answer = 0;

		const int N = x.size();

		vector<int> ys, xs;
		for(int i=0; i<N; ++i)
			for(int dy=-T; dy<=+T; ++dy)
				ys.push_back(y[i]+dy);
		for(int i=0; i<N; ++i)
			for(int dx=-T; dx<=+T; ++dx)
				xs.push_back(x[i]+dx);

		for(int i=0; i<xs.size(); ++i)
		for(int k=0; k<ys.size(); ++k)
		{
			int Y = ys[k];
			int X = xs[i];
			vector<unsigned int> ds;
			for(int j=0; j<N; ++j) {
				unsigned int d = distance(Y,X,A,y[j],x[j]);
				if( d <= T )
					ds.push_back(d);
			}
			sort( ds.begin(), ds.end() );
			int e=T, c=0;
			for(int j=0; j<ds.size() && ds[j]<=e; ++j) 
				e-=ds[j], ++c;
			answer = max(answer, c);
		}
		return answer;
	}

	static unsigned int distance(int Y, int X, int A, int y, int x)
	{
		unsigned int yd = (y<Y ? Y-y : Y+A<y ? y-(Y+A) : 0);
		unsigned int xd = (x<X ? X-x : X+A<x ? x-(X+A) : 0);
		return xd + yd;
	}
};

// 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(_, CrouchingAmoebas().count(x, y, A, T));}
int main(){

CASE(0)
	int x_[] = {0,0};
	  vector <int> x(x_, x_+sizeof(x_)/sizeof(*x_)); 
	int y_[] = {0,1};
	  vector <int> y(y_, y_+sizeof(y_)/sizeof(*y_)); 
	int A = 1; 
	int T = 1; 
	int _ = 2; 
END
CASE(1)
	int x_[] = {0,1,2};
	  vector <int> x(x_, x_+sizeof(x_)/sizeof(*x_)); 
	int y_[] = {1,2,0};
	  vector <int> y(y_, y_+sizeof(y_)/sizeof(*y_)); 
	int A = 1; 
	int T = 1; 
	int _ = 2; 
END
CASE(2)
	int x_[] = {0,1,2};
	  vector <int> x(x_, x_+sizeof(x_)/sizeof(*x_)); 
	int y_[] = {1,2,0};
	  vector <int> y(y_, y_+sizeof(y_)/sizeof(*y_)); 
	int A = 1; 
	int T = 2; 
	int _ = 3; 
END
CASE(3)
	int x_[] = {0,0,3,3};
	  vector <int> x(x_, x_+sizeof(x_)/sizeof(*x_)); 
	int y_[] = {0,3,0,3};
	  vector <int> y(y_, y_+sizeof(y_)/sizeof(*y_)); 
	int A = 2; 
	int T = 4; 
	int _ = 4; 
END
CASE(4)
	int x_[] = {-1000000000,1000000000};
	  vector <int> x(x_, x_+sizeof(x_)/sizeof(*x_)); 
	int y_[] = {-1000000000,1000000000};
	  vector <int> y(y_, y_+sizeof(y_)/sizeof(*y_)); 
	int A = 1; 
	int T = 15; 
	int _ = 1; 
END
/*
CASE(5)
	int x_[] = ;
	  vector <int> x(x_, x_+sizeof(x_)/sizeof(*x_)); 
	int y_[] = ;
	  vector <int> y(y_, y_+sizeof(y_)/sizeof(*y_)); 
	int A = ; 
	int T = ; 
	int _ = ; 
END
CASE(6)
	int x_[] = ;
	  vector <int> x(x_, x_+sizeof(x_)/sizeof(*x_)); 
	int y_[] = ;
	  vector <int> y(y_, y_+sizeof(y_)/sizeof(*y_)); 
	int A = ; 
	int T = ; 
	int _ = ; 
END
*/
}
// END CUT HERE