結果

問題 No.2102 [Cherry Alpha *] Conditional Reflection
コンテスト
ユーザー C
提出日時 2026-11-24 15:01:41
言語 C++23(gcc16)
(gcc 16.2.0 + boost 1.92.0 + ACL)
コンパイル:
g++-16 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc16.so -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 122 ms / 3,000 ms
+ 527µs
コード長 1,556 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 6,938 ms
コンパイル使用メモリ 421,308 KB
実行使用メモリ 215,960 KB
最終ジャッジ日時 2026-11-24 15:02:06
合計ジャッジ時間 19,404 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge6_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 72
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC optimize("O3")
#if defined(__x86_64__) || defined(__i386__)
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#endif
#endif
#include <bits/stdc++.h>
#include <atcoder/all>
#define each(x, v) for (auto&& x : v)
#define each2(x, y, v) for (auto&& [x, y] : v)
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(x) begin(x),end(x)
#define sz(x) (int)(x).size()
using namespace std;
using namespace atcoder;
using ll=long long;
using ull=unsigned long long;
using ld=long double;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vi>;
using pll=pair<ll,ll>;
using pi=pair<int,int>;

// using mint=modint998244353;
// using mint=modint1000000007;
// using mint2=static_modint<2>;

// using mint=LazyMontgomeryModInt<998244353>;
// using vm=vector<mint>;
// using vvm=vector<vm>;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
	int N;
	cin>>N;
	mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
	static ull w[1000000][26];
	rep(i,0,1000000)rep(j,0,26)w[i][j]=rng();
	unordered_set<ull>D;
	rep(i,0,N){
		string s;
		cin>>s;
		ull h=0;
		rep(i,0,sz(s))h^=w[i][s[i]-'a'];
		if(D.find(h)!=D.end()){
			cout<<"Yes\n";
		}else{
			bool no=true;
			rep(i,1,sz(s)){
				auto a=s[i-1]-'a',b=s[i]-'a';
				ull nh=h^w[i-1][a]^w[i][b]^w[i-1][b]^w[i][a];
				if(D.find(nh)!=D.end()){
					no=false;
					cout<<"Yes\n";
					break;
				}
			}
			if(no)cout<<"No\n";
		}
		D.insert(h);
	}
}
0