結果

問題 No.2102 [Cherry Alpha *] Conditional Reflection
ユーザー kotatsugame
提出日時 2022-10-15 00:19:43
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 620 bytes
コンパイル時間 1,003 ms
コンパイル使用メモリ 73,216 KB
実行使用メモリ 15,232 KB
最終ジャッジ日時 2024-06-26 18:22:16
合計ジャッジ時間 26,396 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 12 WA * 58
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<set>
using namespace std;
const int mod=1000000097;
long base[1<<20];
int N;
int main()
{
	base[0]=1;
	for(int i=1;i<1<<20;i++)base[i]=base[i-1]*3%mod;
	cin>>N;
	set<int>V;
	for(;N--;)
	{
		string S;cin>>S;
		int now=0;
		for(int i=0;i<S.size();i++)now=(now+base[i]*S[i])%mod;
		bool fn=V.find(now)!=V.end();
		for(int i=1;i<S.size();i++)
		{
			int tmp=now;
			tmp=(tmp-base[i-1]*S[i-1])%mod;
			tmp=(tmp-base[i]*S[i])%mod;
			tmp=(tmp+base[i-1]*S[i])%mod;
			tmp=(tmp+base[i]*S[i-1])%mod;
			if(V.find((tmp+mod)%mod)!=V.end())fn=true;
		}
		cout<<(fn?"Yes\n":"No\n");
		V.insert(now);
	}
}
0