結果

問題 No.1292 パタパタ三角形
ユーザー HaaHaa
提出日時 2020-11-20 21:48:56
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 63 ms / 2,000 ms
コード長 833 bytes
コンパイル時間 1,681 ms
コンパイル使用メモリ 173,276 KB
実行使用メモリ 12,828 KB
最終ジャッジ日時 2023-09-30 19:07:16
合計ジャッジ時間 2,722 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 28 ms
5,252 KB
testcase_08 AC 28 ms
5,328 KB
testcase_09 AC 48 ms
12,476 KB
testcase_10 AC 51 ms
12,464 KB
testcase_11 AC 48 ms
12,244 KB
testcase_12 AC 59 ms
12,828 KB
testcase_13 AC 63 ms
12,812 KB
testcase_14 AC 7 ms
4,376 KB
testcase_15 AC 7 ms
4,376 KB
testcase_16 AC 7 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(v) v.begin(),v.end()
constexpr ll MOD=1000000007;
constexpr ll INF=1e18;

int main(){
	string s; cin >> s;
	int n=s.size();
	set<pair<int,int>> st;
	st.insert({0,0});
	string p0[3]={"abc","bca","cab"};
	string p1[3]={"cab","abc","bca"};
	int x=0, y=0;
	REP(i,n){
		int p=((y+600000)/2+x*2+600000)%3;
		if(y%2==0){
			if(s[i]==p0[p][0])
				y++;
			else if(s[i]==p0[p][1])
				y--;
			else
				y++,x--;
		}
		else{
			if(s[i]==p1[p][0])
				y++;
			else if(s[i]==p1[p][1])
				y--;
			else
				y--,x++;
		}
		//cout << x << ' ' << y << endl;
		//cout << st.count({x,y}) << endl;
		st.insert({x,y});
	}
	cout << st.size() << endl;
	return 0;
}
0