結果

問題 No.1292 パタパタ三角形
ユーザー takumattakumat
提出日時 2020-11-20 22:31:24
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 2,528 bytes
コンパイル時間 2,627 ms
コンパイル使用メモリ 222,888 KB
実行使用メモリ 15,968 KB
最終ジャッジ日時 2023-09-30 19:36:25
合計ジャッジ時間 4,024 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 1 ms
4,388 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 43 ms
6,080 KB
testcase_08 AC 43 ms
6,004 KB
testcase_09 AC 77 ms
15,420 KB
testcase_10 AC 73 ms
15,264 KB
testcase_11 AC 74 ms
15,160 KB
testcase_12 AC 87 ms
15,968 KB
testcase_13 AC 86 ms
15,940 KB
testcase_14 AC 22 ms
4,380 KB
testcase_15 AC 22 ms
4,376 KB
testcase_16 AC 22 ms
4,376 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