結果

問題 No.2102 [Cherry Alpha *] Conditional Reflection
ユーザー kotatsugamekotatsugame
提出日時 2022-10-15 00:27:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,018 ms / 3,000 ms
コード長 1,123 bytes
コンパイル時間 767 ms
コンパイル使用メモリ 75,940 KB
実行使用メモリ 28,008 KB
最終ジャッジ日時 2023-09-09 01:16:54
合計ジャッジ時間 50,540 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
15,800 KB
testcase_01 AC 41 ms
15,680 KB
testcase_02 AC 543 ms
21,176 KB
testcase_03 AC 646 ms
22,892 KB
testcase_04 AC 568 ms
21,156 KB
testcase_05 AC 444 ms
18,656 KB
testcase_06 AC 624 ms
21,552 KB
testcase_07 AC 525 ms
18,860 KB
testcase_08 AC 231 ms
15,948 KB
testcase_09 AC 587 ms
22,020 KB
testcase_10 AC 312 ms
17,756 KB
testcase_11 AC 241 ms
18,668 KB
testcase_12 AC 466 ms
20,652 KB
testcase_13 AC 713 ms
23,792 KB
testcase_14 AC 498 ms
19,900 KB
testcase_15 AC 677 ms
21,812 KB
testcase_16 AC 881 ms
25,108 KB
testcase_17 AC 355 ms
18,264 KB
testcase_18 AC 593 ms
20,748 KB
testcase_19 AC 353 ms
19,096 KB
testcase_20 AC 766 ms
24,212 KB
testcase_21 AC 365 ms
16,348 KB
testcase_22 AC 973 ms
25,980 KB
testcase_23 AC 997 ms
25,976 KB
testcase_24 AC 1,018 ms
25,956 KB
testcase_25 AC 999 ms
25,968 KB
testcase_26 AC 988 ms
26,048 KB
testcase_27 AC 977 ms
25,992 KB
testcase_28 AC 973 ms
26,024 KB
testcase_29 AC 984 ms
25,968 KB
testcase_30 AC 977 ms
25,968 KB
testcase_31 AC 976 ms
26,032 KB
testcase_32 AC 975 ms
26,208 KB
testcase_33 AC 974 ms
25,960 KB
testcase_34 AC 977 ms
26,040 KB
testcase_35 AC 984 ms
25,972 KB
testcase_36 AC 1,013 ms
25,980 KB
testcase_37 AC 1,001 ms
26,032 KB
testcase_38 AC 976 ms
26,020 KB
testcase_39 AC 997 ms
25,988 KB
testcase_40 AC 963 ms
25,988 KB
testcase_41 AC 987 ms
26,240 KB
testcase_42 AC 756 ms
22,764 KB
testcase_43 AC 750 ms
22,604 KB
testcase_44 AC 742 ms
22,580 KB
testcase_45 AC 742 ms
22,604 KB
testcase_46 AC 742 ms
22,596 KB
testcase_47 AC 609 ms
19,860 KB
testcase_48 AC 609 ms
19,836 KB
testcase_49 AC 608 ms
19,788 KB
testcase_50 AC 613 ms
19,840 KB
testcase_51 AC 605 ms
19,768 KB
testcase_52 AC 274 ms
17,352 KB
testcase_53 AC 275 ms
17,444 KB
testcase_54 AC 275 ms
17,412 KB
testcase_55 AC 351 ms
15,708 KB
testcase_56 AC 350 ms
15,680 KB
testcase_57 AC 350 ms
15,716 KB
testcase_58 AC 277 ms
16,912 KB
testcase_59 AC 1,002 ms
28,008 KB
testcase_60 AC 236 ms
15,624 KB
testcase_61 AC 349 ms
15,724 KB
testcase_62 AC 61 ms
15,912 KB
testcase_63 AC 409 ms
15,692 KB
testcase_64 AC 412 ms
15,800 KB
testcase_65 AC 464 ms
15,816 KB
testcase_66 AC 351 ms
15,704 KB
testcase_67 AC 542 ms
15,928 KB
testcase_68 AC 297 ms
15,688 KB
testcase_69 AC 529 ms
15,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<set>
#include<array>
using namespace std;
const int n=3;
using Hash=array<int,n>;
const Hash mod={1000000097,1000000087,1000000093};
const Hash B={1198,19285,51616};
Hash Base[1<<20];
Hash operator+(Hash lhs,const Hash&rhs)
{
	for(int i=0;i<n;i++)lhs[i]=(lhs[i]+rhs[i])%mod[i];
	return lhs;
}
Hash operator-(Hash lhs,const Hash&rhs)
{
	for(int i=0;i<n;i++)lhs[i]=(lhs[i]-rhs[i]+mod[i])%mod[i];
	return lhs;
}
Hash operator*(Hash lhs,const int v)
{
	for(int i=0;i<n;i++)lhs[i]=(long)lhs[i]*v%mod[i];
	return lhs;
}
Hash operator*(Hash lhs,const Hash&rhs)
{
	for(int i=0;i<n;i++)lhs[i]=(long)lhs[i]*rhs[i]%mod[i];
	return lhs;
}
int N;
int main()
{
	for(int i=0;i<n;i++)Base[0][i]=1;
	for(int i=1;i<1<<20;i++)Base[i]=Base[i-1]*B;
	cin>>N;
	set<Hash>V;
	for(;N--;)
	{
		string S;cin>>S;
		Hash now{};
		for(int i=0;i<S.size();i++)now=now+Base[i]*S[i];
		bool fn=V.find(now)!=V.end();
		for(int i=1;i<S.size();i++)
		{
			Hash tmp=now;
			tmp=tmp+Base[i-1]*S[i]-Base[i-1]*S[i-1]+Base[i]*S[i-1]-Base[i]*S[i];
			if(V.find(tmp)!=V.end())fn=true;
		}
		cout<<(fn?"Yes\n":"No\n");
		V.insert(now);
	}
}
0