結果

問題 No.1292 パタパタ三角形
ユーザー kotatsugamekotatsugame
提出日時 2020-11-20 21:33:19
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 69 ms / 2,000 ms
コード長 636 bytes
コンパイル時間 793 ms
コンパイル使用メモリ 77,452 KB
実行使用メモリ 12,928 KB
最終ジャッジ日時 2024-07-23 12:42:06
合計ジャッジ時間 1,744 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-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