結果

問題 No.2102 [Cherry Alpha *] Conditional Reflection
ユーザー 👑 NachiaNachia
提出日時 2022-10-15 03:10:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 627 ms / 3,000 ms
コード長 2,063 bytes
コンパイル時間 2,463 ms
コンパイル使用メモリ 130,104 KB
実行使用メモリ 75,128 KB
最終ジャッジ日時 2023-09-09 02:03:47
合計ジャッジ時間 29,655 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
26,356 KB
testcase_01 AC 16 ms
26,412 KB
testcase_02 AC 183 ms
35,844 KB
testcase_03 AC 232 ms
36,648 KB
testcase_04 AC 190 ms
36,600 KB
testcase_05 AC 118 ms
34,732 KB
testcase_06 AC 198 ms
37,096 KB
testcase_07 AC 277 ms
34,488 KB
testcase_08 AC 41 ms
31,660 KB
testcase_09 AC 218 ms
34,992 KB
testcase_10 AC 81 ms
32,208 KB
testcase_11 AC 86 ms
30,352 KB
testcase_12 AC 155 ms
34,180 KB
testcase_13 AC 266 ms
37,160 KB
testcase_14 AC 151 ms
35,564 KB
testcase_15 AC 220 ms
38,416 KB
testcase_16 AC 324 ms
40,120 KB
testcase_17 AC 179 ms
31,804 KB
testcase_18 AC 275 ms
34,648 KB
testcase_19 AC 112 ms
32,920 KB
testcase_20 AC 288 ms
37,908 KB
testcase_21 AC 59 ms
34,932 KB
testcase_22 AC 350 ms
40,708 KB
testcase_23 AC 349 ms
40,724 KB
testcase_24 AC 345 ms
40,708 KB
testcase_25 AC 344 ms
41,196 KB
testcase_26 AC 349 ms
40,756 KB
testcase_27 AC 357 ms
40,680 KB
testcase_28 AC 346 ms
41,084 KB
testcase_29 AC 356 ms
40,684 KB
testcase_30 AC 351 ms
40,712 KB
testcase_31 AC 352 ms
40,748 KB
testcase_32 AC 343 ms
40,688 KB
testcase_33 AC 344 ms
40,736 KB
testcase_34 AC 354 ms
40,816 KB
testcase_35 AC 352 ms
40,724 KB
testcase_36 AC 350 ms
40,688 KB
testcase_37 AC 348 ms
40,720 KB
testcase_38 AC 341 ms
40,816 KB
testcase_39 AC 356 ms
40,764 KB
testcase_40 AC 346 ms
40,780 KB
testcase_41 AC 354 ms
40,732 KB
testcase_42 AC 504 ms
68,332 KB
testcase_43 AC 519 ms
68,440 KB
testcase_44 AC 494 ms
68,304 KB
testcase_45 AC 526 ms
68,240 KB
testcase_46 AC 501 ms
68,300 KB
testcase_47 AC 554 ms
71,452 KB
testcase_48 AC 552 ms
71,516 KB
testcase_49 AC 529 ms
71,408 KB
testcase_50 AC 555 ms
71,748 KB
testcase_51 AC 578 ms
71,596 KB
testcase_52 AC 625 ms
74,812 KB
testcase_53 AC 627 ms
74,820 KB
testcase_54 AC 616 ms
74,704 KB
testcase_55 AC 605 ms
75,128 KB
testcase_56 AC 587 ms
74,920 KB
testcase_57 AC 586 ms
74,900 KB
testcase_58 AC 160 ms
61,104 KB
testcase_59 AC 555 ms
64,252 KB
testcase_60 AC 41 ms
31,796 KB
testcase_61 AC 515 ms
74,952 KB
testcase_62 AC 26 ms
27,988 KB
testcase_63 AC 300 ms
71,692 KB
testcase_64 AC 305 ms
69,772 KB
testcase_65 AC 354 ms
71,516 KB
testcase_66 AC 451 ms
71,652 KB
testcase_67 AC 106 ms
54,392 KB
testcase_68 AC 373 ms
61,024 KB
testcase_69 AC 106 ms
54,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#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);
    
    vector<int> 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<pair<int, int>, 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<int, int> 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<string, int> 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<int, int> 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<int> 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;


0