Artifact Content
Not logged in

Artifact 81e3457a1a1154c2cfe11654b44e8446082b31ab


#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 PastingPaintingDivOne { public:
	vector<long long> countColors(vector <string> c, int T)
	{
		int H = c.size();
		int W = c[0].size();

		int TR = min(T, 50+T%50);
		vector<string> shifted(H+TR+50, string(W+H, '.'));

		// TR
		for(int i=0; i<TR; ++i)
			for(int y=0; y<H; ++y)
			for(int x=0; x<W; ++x)
				if(c[y][x] != '.')
					shifted[i+y][x+H-1-y] = c[y][x];

		LL r=0, g=0, b=0;
		for(int y=0; y<shifted.size(); ++y)
		for(int x=0; x<shifted[y].size(); ++x)
			if(shifted[y][x]=='R') r++;
			else if(shifted[y][x]=='G') g++;
			else if(shifted[y][x]=='B') b++;

		// 50 more
		for(int i=TR; i<TR+50; ++i)
			for(int y=0; y<H; ++y)
			for(int x=0; x<W; ++x)
				if(c[y][x] != '.')
					shifted[i+y][x+H-1-y] = c[y][x];

		LL rr=0, gg=0, bb=0;
		for(int y=0; y<shifted.size(); ++y)
		for(int x=0; x<shifted[y].size(); ++x)
			if(shifted[y][x]=='R') rr++;
			else if(shifted[y][x]=='G') gg++;
			else if(shifted[y][x]=='B') bb++;

		vector<LL> answer;
		answer.push_back((rr-r)*(T-TR)/50 + r);
		answer.push_back((gg-g)*(T-TR)/50 + g);
		answer.push_back((bb-b)*(T-TR)/50 + b);
		return answer;
	}
};

// 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 vector<long long>& Expected, const vector<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(_, PastingPaintingDivOne().countColors(clipboard, T));}
int main(){

CASE(0)
	string clipboard_[] = {
"..G",
"R..",
"BG."
};
	  vector <string> clipboard(clipboard_, clipboard_+sizeof(clipboard_)/sizeof(*clipboard_)); 
	int T = 3; 
	long long __[] = {3, 4, 3 };
	  vector<long long> _(__, __+sizeof(__)/sizeof(*__)); 
END
CASE(1)
	string clipboard_[] = {
"R...",
"....",
"....",
"...R"
};
	  vector <string> clipboard(clipboard_, clipboard_+sizeof(clipboard_)/sizeof(*clipboard_)); 
	int T = 2; 
	long long __[] = {4, 0, 0 };
	  vector<long long> _(__, __+sizeof(__)/sizeof(*__)); 
END
CASE(2)
	string clipboard_[] = {"RGB"};
	  vector <string> clipboard(clipboard_, clipboard_+sizeof(clipboard_)/sizeof(*clipboard_)); 
	int T = 100000; 
	long long __[] = {100000, 100000, 100000 };
	  vector<long long> _(__, __+sizeof(__)/sizeof(*__)); 
END
CASE(3)
	string clipboard_[] = {"."};
	  vector <string> clipboard(clipboard_, clipboard_+sizeof(clipboard_)/sizeof(*clipboard_)); 
	int T = 1000000000; 
	long long __[] = {0, 0, 0 };
	  vector<long long> _(__, __+sizeof(__)/sizeof(*__)); 
END
CASE(4)
	string clipboard_[] = {
"RB.",
".G."
}
;
	  vector <string> clipboard(clipboard_, clipboard_+sizeof(clipboard_)/sizeof(*clipboard_)); 
	int T = 100; 
	long long __[] = {100, 1, 100 };
	  vector<long long> _(__, __+sizeof(__)/sizeof(*__)); 
END
CASE(5)
	string clipboard_[] = {
"..........G..........",
".........G.G.........",
"........G...G........",
".......G.....G.......",
"......G..B.B..G......",
".....G...B.B...G.....",
"....G...........G....",
"...G...R.....R...G...",
"..G.....RRRRRR....G..",
".G..........RR.....G.",
"GGGGGGGGGGGGGGGGGGGGG"
};
	  vector <string> clipboard(clipboard_, clipboard_+sizeof(clipboard_)/sizeof(*clipboard_)); 
	int T = 1000000000; 
	long long __[] = {2000000018, 17000000048, 2000000005 };
	  vector<long long> _(__, __+sizeof(__)/sizeof(*__)); 
END
/*
CASE(6)
	string clipboard_[] = ;
	  vector <string> clipboard(clipboard_, clipboard_+sizeof(clipboard_)/sizeof(*clipboard_)); 
	int T = ; 
	long long __[] = ;
	  vector<long long> _(__, __+sizeof(__)/sizeof(*__)); 
END
CASE(7)
	string clipboard_[] = ;
	  vector <string> clipboard(clipboard_, clipboard_+sizeof(clipboard_)/sizeof(*clipboard_)); 
	int T = ; 
	long long __[] = ;
	  vector<long long> _(__, __+sizeof(__)/sizeof(*__)); 
END
*/
}
// END CUT HERE