結果

問題 No.1292 パタパタ三角形
ユーザー kaede2020kaede2020
提出日時 2020-11-23 10:37:45
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 64 ms / 2,000 ms
コード長 1,053 bytes
コンパイル時間 1,759 ms
コンパイル使用メモリ 175,392 KB
実行使用メモリ 16,256 KB
最終ジャッジ日時 2024-07-23 17:22:14
合計ジャッジ時間 2,654 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

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