結果

問題 No.1292 パタパタ三角形
ユーザー mamimume____momamimume____mo
提出日時 2020-11-20 22:23:26
言語 C++14
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 64 ms / 2,000 ms
コード長 690 bytes
コンパイル時間 1,447 ms
使用メモリ 15,972 KB
最終ジャッジ日時 2023-02-23 18:57:21
合計ジャッジ時間 3,037 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 1 ms
6,256 KB
testcase_01 AC 2 ms
6,192 KB
testcase_02 AC 1 ms
6,172 KB
testcase_03 AC 1 ms
6,192 KB
testcase_04 AC 2 ms
6,200 KB
testcase_05 AC 2 ms
6,204 KB
testcase_06 AC 1 ms
6,192 KB
testcase_07 AC 28 ms
6,196 KB
testcase_08 AC 29 ms
6,280 KB
testcase_09 AC 56 ms
15,332 KB
testcase_10 AC 59 ms
15,340 KB
testcase_11 AC 60 ms
15,180 KB
testcase_12 AC 64 ms
15,872 KB
testcase_13 AC 64 ms
15,972 KB
testcase_14 AC 6 ms
6,280 KB
testcase_15 AC 7 ms
6,252 KB
testcase_16 AC 7 ms
6,260 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
	string s;
	cin >> s;

	char vertical_side = 'c';
	char right_side = 'b';
	char left_side = 'a';
	bool is_up = true;

	int x = 0,y = 0;
	map<pair<int,int>,bool> mp;
	mp[make_pair(x,y)] = true;
	for(int i = 0;i < s.size();i++){
		if(s[i] == vertical_side){
			if(is_up){
				y--;
			}
			else{
				y++;
			}
			is_up = !is_up;
		}
		else{
			if(s[i] == right_side){
				x++;
				swap(right_side,left_side);
				swap(vertical_side,right_side);
			}
			else{
				x--;
				swap(right_side,left_side);
				swap(vertical_side,left_side);
			}
			// 
			is_up = !is_up;
		}
		mp[make_pair(x,y)] = true;
	}

	cout << mp.size() << endl;
}
0