結果

問題 No.2102 [Cherry Alpha *] Conditional Reflection
ユーザー momoyuumomoyuu
提出日時 2022-10-15 00:58:43
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,387 bytes
コンパイル時間 3,182 ms
コンパイル使用メモリ 253,196 KB
実行使用メモリ 20,792 KB
最終ジャッジ日時 2023-09-09 01:35:30
合計ジャッジ時間 38,647 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 348 ms
5,496 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 185 ms
4,384 KB
testcase_09 WA -
testcase_10 AC 232 ms
4,956 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 314 ms
4,380 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 566 ms
8,460 KB
testcase_43 AC 568 ms
8,512 KB
testcase_44 AC 552 ms
8,564 KB
testcase_45 AC 547 ms
8,464 KB
testcase_46 AC 554 ms
8,620 KB
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 AC 73 ms
20,720 KB
testcase_53 AC 75 ms
20,764 KB
testcase_54 AC 74 ms
20,792 KB
testcase_55 AC 127 ms
4,384 KB
testcase_56 AC 126 ms
4,388 KB
testcase_57 AC 127 ms
4,384 KB
testcase_58 AC 77 ms
12,380 KB
testcase_59 AC 852 ms
12,600 KB
testcase_60 AC 174 ms
4,384 KB
testcase_61 AC 127 ms
4,384 KB
testcase_62 AC 15 ms
4,384 KB
testcase_63 AC 138 ms
4,384 KB
testcase_64 AC 140 ms
4,380 KB
testcase_65 AC 148 ms
4,384 KB
testcase_66 WA -
testcase_67 AC 353 ms
4,380 KB
testcase_68 AC 78 ms
4,380 KB
testcase_69 AC 351 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template<class t> using vc = vector<t>;
template<class t> using vvc = vc<vc<t>>;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using vi = vc<int>;
using vvi = vvc<int>;
using vl = vc<ll>;
using vvl = vvc<ll>;

#define rep(i,a,b) for (int i = (int)(a); i < (int)(b); i++)
#define irep(i,a,b) for (int i = (int)(a); i > (int)(b); i--)
#define all(a) a.begin(),a.end()
#define print(n) cout << n << '\n'
#define pritn(n) print(n)
#define printv(n,a) {copy(all(n),ostream_iterator<a>(cout," ")); cout<<"\n";}
#define printvv(n,a) {for(auto itr:n) printv(itr,a);}
#define rup(a,b) (a+b-1)/b
#define input(A,N) rep(i,0,N) cin>>A[i]
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)

const ll m2 = 1000000007;
const ll b2 = 1009;
const ll m3 = 1000000009;
const ll b3 = 2009;
const ll m4 = 2147483587;
const ll b4 = 2147483583;
//https://gist.github.com/privet-kitty/295ac9202b7abb3039b493f8238bf40f#file-modulus-random-base-pair64-txt
struct rhash{
    int n;
    ll mod,B;
    vc<ll> sum;
    vc<ll> powb;
    string s;
    rhash(string &s,ll mod,ll B):mod(mod),B(B),s(s){
        n = s.size();
        sum = vc<ll>(n+1,0);
        powb = vc<ll>(n+1,1);
        for(int i = 0;i<n;i++){
            sum[i+1] = (sum[i]*B%mod+(s[i]))%mod;
            powb[i+1] = (powb[i]*B)%mod;
        }
    }
    ll get(int l,int r){
        ll tmp = sum[r] - sum[l]*powb[r-l]%mod;
        if(tmp<0) tmp += mod;
        return tmp;
    }

    ll inv(int i){
        ll tmp = sum[n];
        tmp -= powb[n-i-1]*(s[i]) + powb[n-i-2]*(s[i+1]);
        tmp += powb[n-i-2]*(s[i]) + powb[n-i-1]*(s[i+1]);
        tmp %= mod;
        if(tmp<0) tmp += mod;
        return tmp;
    }
};


int main(){
    cout << fixed << setprecision(15);
    
    int n;
    cin>>n;
    // unordered_set<string> d;
    set<ll> d;
    rep(i,0,n){
        string now;
        cin>>now;
        rhash hash(now,m2,b2);
        bool p =false;
        if(d.find(hash.get(0,now.size()))!=d.end()) p = true;
        rep(i,0,now.size()-1){
            ll nn = hash.inv(i);
            if(d.find(nn)!=d.end())p = true;
            if(p) break;
        }
        d.insert(hash.get(0,now.size()));
        if(p) print("Yes");
        else print("No");
    }
    
    //system("pause");
    return 0;
}
0