結果

問題 No.2102 [Cherry Alpha *] Conditional Reflection
ユーザー 👑 NachiaNachia
提出日時 2022-10-15 02:39:49
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,726 bytes
コンパイル時間 2,087 ms
コンパイル使用メモリ 124,848 KB
実行使用メモリ 107,664 KB
最終ジャッジ日時 2023-09-09 02:00:46
合計ジャッジ時間 38,621 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
26,356 KB
testcase_01 AC 18 ms
26,596 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 AC 511 ms
37,200 KB
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 AC 314 ms
33,776 KB
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 AC 1,129 ms
102,672 KB
testcase_48 AC 1,092 ms
102,904 KB
testcase_49 AC 1,080 ms
102,796 KB
testcase_50 AC 1,077 ms
102,744 KB
testcase_51 AC 1,071 ms
102,756 KB
testcase_52 AC 1,097 ms
107,624 KB
testcase_53 AC 1,075 ms
107,556 KB
testcase_54 AC 1,089 ms
107,616 KB
testcase_55 AC 1,129 ms
107,664 KB
testcase_56 AC 1,085 ms
107,520 KB
testcase_57 AC 1,118 ms
107,504 KB
testcase_58 AC 645 ms
76,284 KB
testcase_59 WA -
testcase_60 RE -
testcase_61 AC 1,112 ms
107,512 KB
testcase_62 WA -
testcase_63 AC 519 ms
71,936 KB
testcase_64 WA -
testcase_65 WA -
testcase_66 WA -
testcase_67 AC 146 ms
54,408 KB
testcase_68 WA -
testcase_69 AC 131 ms
54,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;


0