結果

問題 No.1292 パタパタ三角形
ユーザー 沙耶花沙耶花
提出日時 2020-05-02 15:42:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 55 ms / 2,000 ms
コード長 941 bytes
コンパイル時間 2,251 ms
コンパイル使用メモリ 209,236 KB
実行使用メモリ 12,960 KB
最終ジャッジ日時 2023-09-18 01:30:40
合計ジャッジ時間 3,517 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 50 ms
12,020 KB
testcase_08 AC 55 ms
11,992 KB
testcase_09 AC 47 ms
11,768 KB
testcase_10 AC 48 ms
11,588 KB
testcase_11 AC 49 ms
12,396 KB
testcase_12 AC 27 ms
12,688 KB
testcase_13 AC 25 ms
11,704 KB
testcase_14 AC 38 ms
11,720 KB
testcase_15 AC 39 ms
12,960 KB
testcase_16 AC 38 ms
12,784 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:35:25: 警告: ‘ind’ may be used uninitialized [-Wmaybe-uninitialized]
   35 |                         if(ind==1)x+=L,y-=1.0;
      |                         ^~
main.cpp:24:21: 備考: ‘ind’ はここで定義されています
   24 |                 int ind;
      |                     ^~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000



int main(){
	
	vector<string> T = {"abc","cab","bca"};
	
	string S;
	cin>>S;

	vector<pair<long double,long double>> A;
	
	long double x=0.0,y=0.0;
	A.emplace_back(x,y);
	
	int now = 0;
	long double L = 1.0;
	for(int i=0;i<S.size();i++){
		int ind;
		for(int j=0;j<3;j++){
			if(T[now][j]==S[i]){
				ind = j;
				break;
			}
		}
		
		now = (now+ind)%3;
		if(i%2==0){
			if(ind==0)x-=L,y-=1.0;
			if(ind==1)x+=L,y-=1.0;
			if(ind==2)y+=2.0;
		}
		else{
			if(ind==0)x+=L,y+=1.0;
			if(ind==1)y-=2.0;
			if(ind==2)x-=L,y+=1.0;
		}
		A.emplace_back(x,y);
	}
	
	sort(A.begin(),A.end());
	long double eps = 1e-10;
	int ans = 0;
	
	for(int i=0;i<A.size();i++){
		if(i==0||abs(A[i].first-A[i-1].first)>eps||abs(A[i].second-A[i-1].second)>eps)ans++;
	}
	cout<<ans<<endl;
	
	
	return 0;
}
0