結果

問題 No.1292 パタパタ三角形
ユーザー takumattakumat
提出日時 2020-11-20 22:31:24
言語 C++17
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 86 ms / 2,000 ms
コード長 2,528 bytes
コンパイル時間 2,353 ms
使用メモリ 16,080 KB
最終ジャッジ日時 2023-02-23 19:03:59
合計ジャッジ時間 4,027 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 2 ms
6,268 KB
testcase_01 AC 1 ms
6,180 KB
testcase_02 AC 1 ms
6,248 KB
testcase_03 AC 2 ms
6,256 KB
testcase_04 AC 1 ms
6,164 KB
testcase_05 AC 2 ms
6,264 KB
testcase_06 AC 2 ms
6,188 KB
testcase_07 AC 43 ms
6,272 KB
testcase_08 AC 43 ms
6,244 KB
testcase_09 AC 78 ms
15,464 KB
testcase_10 AC 78 ms
15,368 KB
testcase_11 AC 78 ms
15,368 KB
testcase_12 AC 86 ms
16,004 KB
testcase_13 AC 85 ms
16,080 KB
testcase_14 AC 22 ms
6,184 KB
testcase_15 AC 24 ms
6,248 KB
testcase_16 AC 22 ms
6,172 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//#include <atcoder/all>
#include <bits/stdc++.h>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007LL; //998244353LL

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}

static void A_task();

int main()
{
	A_task();
	fflush(stdout);
	return 0;
}

enum {
	LeftUpper = 0,
	RightUpper,
	Bottom,
	LeftUnder,
	RightUnder,
	Top,
};

static std::pair<int, int> rot(std::map<int, char>& dir, std::pair<int, int> center, char edge)
{
	int nowEdge = 0;
	for (auto d : dir) {
		if (d.second == edge) {
			nowEdge = d.first;
		}
	}

	int x = 0, y = 0;
	switch (nowEdge) {
	case LeftUpper:
		dir[Top] = dir[RightUpper];
		dir[LeftUnder] = dir[Bottom];
		dir[RightUnder] = dir[LeftUpper];
		dir[RightUpper] = dir[Bottom] = dir[LeftUpper] = 0;
		x = 3;
		y = 1;
		break;
	case RightUpper:
		dir[Top] = dir[LeftUpper];
		dir[RightUnder] = dir[Bottom];
		dir[LeftUnder] = dir[RightUpper];
		dir[RightUpper] = dir[Bottom] = dir[LeftUpper] = 0;
		x = -3;
		y = 1;
		break;

	case Bottom:
		dir[LeftUnder] = dir[LeftUpper];
		dir[RightUnder] = dir[RightUpper];
		dir[Top] = dir[Bottom];
		dir[RightUpper] = dir[Bottom] = dir[LeftUpper] = 0;

		x = 0;
		y = -2;
		break;

	case LeftUnder:
		dir[LeftUpper] = dir[Top];
		dir[Bottom] = dir[RightUnder];
		dir[RightUpper] = dir[LeftUnder];
		dir[Top] = dir[LeftUnder] = dir[RightUnder] = 0;
		x = 3;
		y = -1;
		break;

	case RightUnder:
		dir[RightUpper] = dir[Top];
		dir[Bottom] = dir[LeftUnder];
		dir[LeftUpper] = dir[RightUnder];
		dir[Top] = dir[LeftUnder] = dir[RightUnder] = 0;
		x = -3;
		y = -1;
		break;

	case Top:
		dir[LeftUpper] = dir[LeftUnder];
		dir[RightUpper] = dir[RightUnder];
		dir[Bottom] = dir[Top];
		dir[Top] = dir[LeftUnder] = dir[RightUnder] = 0;
		x = 0;
		y = 2;
		break;
	}

	return std::pair<int, int>(center.first + x, center.second + y);
}

static void A_task()
{
	std::string ptn;
	get(ptn);

	std::map<std::pair<int, int>, int> points;
	std::map<int, char> dir;
	dir[LeftUpper] = 'c';
	dir[Bottom] = 'a';
	dir[RightUpper] = 'b';

	std::pair<int, int> center(0, 1);
	points[center] = 1;

	int len = ptn.length();
	for (int i = 0; i < len; i++) {
		center = rot(dir, center, ptn[i]);
		points[center] = 1;
	}
	printf("%d\n", (int)points.size());
}
0