結果
| 問題 |
No.2102 [Cherry Alpha *] Conditional Reflection
|
| コンテスト | |
| ユーザー |
Nachia
|
| 提出日時 | 2022-10-15 02:40:25 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,726 bytes |
| コンパイル時間 | 8,607 ms |
| コンパイル使用メモリ | 163,060 KB |
| 最終ジャッジ日時 | 2025-02-08 06:02:29 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 WA * 11 RE * 39 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <atcoder/dsu>
#include <atcoder/string>
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<string> S(N); rep(i,N) cin >> S[i];
vector<vector<int>> I(1000001);
rep(i,N) I[S[i].size()].push_back(i);
atcoder::dsu ans(N);
rep(L,I.size()) if(L>=2) 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<pair<int, int>, int> Q;
int Qi = 0;
rep(i,sa.size()){
if(i != 0) if(lcp[i-1] < L-2) Qi++;
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<int,int> key = { Qi, max(c1,c2)*1000+min(c1,c2) };
if(Q.count(key)) ans.merge(si, Q[key]);
Q[key] = si;
}
}
rep(L,I.size()) if(L>=1){
map<string, int> Q;
for(int i : I[L]){
if(Q.count(S[i])) ans.merge(Q[S[i]], i);
Q[S[i]] = i;
}
}
vector<int> vis(N);
rep(i,N){
cout << (vis[ans.leader(i)] ? "Yes\n" : "No\n");
vis[ans.leader(i)] = 1;
}
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;
Nachia