結果

問題 No.1292 パタパタ三角形
ユーザー leaf_1415leaf_1415
提出日時 2020-11-20 21:44:13
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 68 ms / 2,000 ms
コード長 1,073 bytes
コンパイル時間 755 ms
コンパイル使用メモリ 88,588 KB
実行使用メモリ 16,008 KB
最終ジャッジ日時 2023-09-30 19:05:32
合計ジャッジ時間 1,749 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 28 ms
6,032 KB
testcase_08 AC 28 ms
6,032 KB
testcase_09 AC 52 ms
15,400 KB
testcase_10 AC 55 ms
15,216 KB
testcase_11 AC 58 ms
15,128 KB
testcase_12 AC 66 ms
16,008 KB
testcase_13 AC 68 ms
15,980 KB
testcase_14 AC 5 ms
4,384 KB
testcase_15 AC 5 ms
4,380 KB
testcase_16 AC 5 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#include <complex>
#define rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define all(x) (x).begin(),(x).end()
#define inf 1e18

using namespace std;

typedef long long llint;
typedef long long ll;
typedef pair<llint, llint> P;

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)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> s;
	ll x = 0, y = 0;
	S.insert(P(0, 0));
	
	for(auto c : s) move(x, y, c), S.insert(P(x, y));
	cout << (int)S.size() << endl;
	
	return 0;
}
0