結果

問題 No.1292 パタパタ三角形
ユーザー kaede2020kaede2020
提出日時 2020-11-23 10:37:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 68 ms / 2,000 ms
コード長 1,053 bytes
コンパイル時間 1,524 ms
コンパイル使用メモリ 171,752 KB
実行使用メモリ 15,900 KB
最終ジャッジ日時 2023-09-30 23:41:05
合計ジャッジ時間 2,757 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 31 ms
5,940 KB
testcase_08 AC 29 ms
5,752 KB
testcase_09 AC 56 ms
15,412 KB
testcase_10 AC 60 ms
15,172 KB
testcase_11 AC 59 ms
15,068 KB
testcase_12 AC 67 ms
15,900 KB
testcase_13 AC 68 ms
15,828 KB
testcase_14 AC 8 ms
4,380 KB
testcase_15 AC 8 ms
4,376 KB
testcase_16 AC 8 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
template <typename T> bool chmax(T &u, const T z) { if (u < z) {u = z; return true;} else return false; }
template <typename T> bool chmin(T &u, const T z) { if (u > z) {u = z; return true;} else return false; }
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
//#define endl "\n"
typedef pair<ll, ll> P;
const ll INF = 1e18;
//using mint = modint1000000007;
//using mint = modint998244353;
//const int INF=INT_MAX;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
//写し
string s;
set<P> S;
void move(ll &x, ll &y, char c)
{
	ll p = ((x+3*y) % 6 + 6) % 6;
	if(c == 'b') p += 2, p %= 6;
	if(c == 'c') p += 4, p %= 6;
	if(p == 0) x--;
	if(p == 1) y++;
	if(p == 2) x++;
	if(p == 3) x--;
	if(p == 4) y--;
	if(p == 5) x++;
}

int main(void)
{
	cin >> s;
	ll x = 0, y = 0;
	S.emplace(0,0);
	for(auto c : s) move(x, y, c), S.insert(P(x, y));
	cout << (int)S.size() << endl;
	return 0;
}
0