結果

問題 No.1292 パタパタ三角形
ユーザー Haa
提出日時 2020-11-20 21:48:56
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 63 ms / 2,000 ms
コード長 833 bytes
コンパイル時間 1,683 ms
コンパイル使用メモリ 175,104 KB
実行使用メモリ 12,800 KB
最終ジャッジ日時 2024-07-23 12:52:11
合計ジャッジ時間 2,618 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

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