結果

問題 No.1292 パタパタ三角形
ユーザー kotatsugamekotatsugame
提出日時 2020-11-20 21:33:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 70 ms / 2,000 ms
コード長 636 bytes
コンパイル時間 591 ms
コンパイル使用メモリ 76,052 KB
実行使用メモリ 12,824 KB
最終ジャッジ日時 2023-09-30 18:58:53
合計ジャッジ時間 1,697 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 30 ms
5,320 KB
testcase_08 AC 28 ms
5,184 KB
testcase_09 AC 46 ms
12,412 KB
testcase_10 AC 51 ms
12,268 KB
testcase_11 AC 49 ms
12,196 KB
testcase_12 AC 70 ms
12,824 KB
testcase_13 AC 57 ms
12,728 KB
testcase_14 AC 7 ms
4,384 KB
testcase_15 AC 7 ms
4,376 KB
testcase_16 AC 7 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    7 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<set>
#include<algorithm>
using namespace std;
string s;
set<pair<int,int> >S;
main()
{
	cin>>s;
	int x=0,y=0;
	string n="abc";
	S.insert(make_pair(x,y));
	for(char t:s)
	{
		if(x%2==0)
		{
			if(n[0]==t)
			{
				x--;
				swap(n[0],n[2]);
			}
			else if(n[1]==t)
			{
				x++;
				y--;
				swap(n[0],n[1]);
			}
			else
			{
				x++;
				swap(n[1],n[2]);
			}
		}
		else
		{
			if(n[0]==t)
			{
				x--;
				y++;
				swap(n[0],n[1]);
			}
			else if(n[1]==t)
			{
				x--;
				swap(n[1],n[2]);
			}
			else
			{
				x++;
				swap(n[0],n[2]);
			}
		}
		S.insert(make_pair(x,y));
	}
	cout<<S.size()<<endl;
}
0