結果

問題 No.1292 パタパタ三角形
ユーザー 沙耶花沙耶花
提出日時 2020-05-02 15:31:32
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 971 bytes
コンパイル時間 2,921 ms
コンパイル使用メモリ 201,156 KB
最終ジャッジ日時 2025-01-10 05:54:42
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7 WA * 7
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:32:27: warning: ‘ind’ may be used uninitialized [-Wmaybe-uninitialized]
   32 |                 now = (now+ind)%3;
      |                       ~~~~^~~~~
main.cpp:24:21: note: ‘ind’ was declared here
   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;

	set<pair<long double,long double>> A;
	
	long double x=0.0,y=0.0;
	A.insert({x,y});
	
	int now = 0;
	long double L = sqrt((long double)3.0)/2.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-=0.5;
			if(ind==1)x+=L,y-=0.5;
			if(ind==2)y+=1.0;
		}
		else{
			if(ind==0)x+=L,y+=0.5;
			if(ind==1)y-=1.0;
			if(ind==2)x-=L,y+=0.5;
		}
		A.insert({x,y});
	}
	
	pair<long double,long double> last = {-1000000.0,-1000000.3};
	int ans = 0;
	
	for(auto a:A){
		if(abs(last.first-a.first)<1e-10&&abs(last.second-a.second)<1e-10){
		}
		else{
			ans++;
		}
		last = a;
	}
	cout<<ans<<endl;
	
	
	return 0;
}
0