#include #include #include #include #include #include #include #include using namespace std; using i32 = int32_t; using u32 = uint32_t; using i64 = int64_t; using u64 = uint64_t; using u128 = __uint128_t; #define rep(i,n) for(int i=0; i<(int)(n); i++) int main(){ int N; cin >> N; vector S(N); rep(i,N) cin >> S[i]; vector> I(1000001); rep(i,N) I[S[i].size()].push_back(i); vector ans(N, 0); rep(L,I.size()) if(L>=3) if(!I[L].empty()){ string s; for(auto& i : I[L]){ s += S[i].substr(2); s += S[i].substr(0, L-2); } auto sa = atcoder::suffix_array(s); auto lcp = atcoder::lcp_array(s, sa); map, int> Q; rep(i,sa.size()){ if(i != 0) if(lcp[i-1] < L-2) Q.clear(); int c = sa[i] / (L*2-4), p = sa[i] % (L*2-4); if(p >= L-1) continue; int si = I[L][c]; int c1 = S[si][p], c2 = S[si][p+1]; pair key = { p, max(c1,c2)*1000+min(c1,c2) }; if(Q.count(key)){ int& v = Q[key]; ans[max(v, si)] = 1; v = min(v, si); } else Q.insert({ key, si }); } } rep(L,I.size()){ if(L==1){ map Q; for(int i : I[L]) /* I[L] sorted */ { if(Q.count(S[i])) ans[i] = 1; else Q[S[i]] = i; } } if(L==2){ map Q; for(int i : I[L]) /* I[L] sorted */ { int c1 = S[i][0], c2 = S[i][1]; int key = max(c1,c2)*1000+min(c1,c2); if(Q.count(key)) ans[i] = 1; else Q[key] = i; } } } vector vis(N); rep(i,N){ cout << (ans[i] ? "Yes\n" : "No\n"); } return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } } ios_do_not_sync_instance;