結果

問題 No.2102 [Cherry Alpha *] Conditional Reflection
ユーザー hourenhouren
提出日時 2022-12-22 11:46:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 429 ms / 3,000 ms
コード長 1,593 bytes
コンパイル時間 1,819 ms
コンパイル使用メモリ 175,316 KB
実行使用メモリ 28,160 KB
最終ジャッジ日時 2024-04-29 03:42:37
合計ジャッジ時間 21,249 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
18,816 KB
testcase_01 AC 20 ms
18,816 KB
testcase_02 AC 175 ms
23,040 KB
testcase_03 AC 233 ms
24,320 KB
testcase_04 AC 189 ms
22,912 KB
testcase_05 AC 122 ms
21,120 KB
testcase_06 AC 197 ms
23,296 KB
testcase_07 AC 191 ms
21,248 KB
testcase_08 AC 44 ms
19,072 KB
testcase_09 AC 214 ms
23,552 KB
testcase_10 AC 82 ms
20,480 KB
testcase_11 AC 80 ms
20,992 KB
testcase_12 AC 151 ms
22,656 KB
testcase_13 AC 272 ms
24,960 KB
testcase_14 AC 151 ms
22,016 KB
testcase_15 AC 223 ms
23,552 KB
testcase_16 AC 327 ms
25,984 KB
testcase_17 AC 127 ms
20,864 KB
testcase_18 AC 223 ms
22,528 KB
testcase_19 AC 108 ms
21,376 KB
testcase_20 AC 295 ms
25,216 KB
testcase_21 AC 67 ms
19,328 KB
testcase_22 AC 417 ms
26,624 KB
testcase_23 AC 399 ms
26,624 KB
testcase_24 AC 419 ms
26,624 KB
testcase_25 AC 414 ms
26,752 KB
testcase_26 AC 413 ms
26,496 KB
testcase_27 AC 384 ms
26,496 KB
testcase_28 AC 383 ms
26,624 KB
testcase_29 AC 392 ms
26,496 KB
testcase_30 AC 387 ms
26,624 KB
testcase_31 AC 372 ms
26,624 KB
testcase_32 AC 389 ms
26,624 KB
testcase_33 AC 369 ms
26,496 KB
testcase_34 AC 370 ms
26,624 KB
testcase_35 AC 369 ms
26,624 KB
testcase_36 AC 366 ms
26,624 KB
testcase_37 AC 370 ms
26,624 KB
testcase_38 AC 365 ms
26,496 KB
testcase_39 AC 377 ms
26,752 KB
testcase_40 AC 376 ms
26,496 KB
testcase_41 AC 367 ms
26,624 KB
testcase_42 AC 283 ms
23,936 KB
testcase_43 AC 305 ms
24,064 KB
testcase_44 AC 322 ms
24,064 KB
testcase_45 AC 315 ms
24,192 KB
testcase_46 AC 310 ms
23,936 KB
testcase_47 AC 233 ms
22,016 KB
testcase_48 AC 236 ms
22,016 KB
testcase_49 AC 236 ms
21,888 KB
testcase_50 AC 230 ms
22,016 KB
testcase_51 AC 224 ms
21,888 KB
testcase_52 AC 37 ms
19,948 KB
testcase_53 AC 37 ms
19,948 KB
testcase_54 AC 36 ms
19,948 KB
testcase_55 AC 91 ms
18,944 KB
testcase_56 AC 91 ms
18,944 KB
testcase_57 AC 91 ms
18,944 KB
testcase_58 AC 37 ms
19,820 KB
testcase_59 AC 429 ms
28,160 KB
testcase_60 AC 33 ms
18,816 KB
testcase_61 AC 91 ms
18,816 KB
testcase_62 AC 25 ms
18,944 KB
testcase_63 AC 81 ms
18,944 KB
testcase_64 AC 82 ms
18,944 KB
testcase_65 AC 118 ms
18,944 KB
testcase_66 AC 91 ms
18,816 KB
testcase_67 AC 50 ms
18,816 KB
testcase_68 AC 41 ms
18,816 KB
testcase_69 AC 47 ms
18,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define fix(x) fixed << setprecision(x)
#define asc(x) x, vector<x>, greater<x>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool chmax(T&a, const T&b){if(a<b){a=b;return 1;}return 0;}
constexpr ll INFLL = (1LL <<62);
constexpr int INF = (1<<30);
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    const ll p = 1e9+7, q = 1e9+9;
    const ll a = 10000019, b = 99999989;
    vector<ll> hp(1e6+1), hq(1e6+1), k(26);
    rep(i,26) k[i] = rand();
    hp[0] = hq[0] = 1;
    rep(i,1e6) hp[i+1] = hp[i] * a % p, hq[i+1] = hq[i] * b % q;
    set<ll> se;
    rep(i,n){
        string s;
        cin >> s;
        int m = s.size();
        ll resp = 0, resq = 0;
        rep(j,m){
            resp = (resp + k[s[j]-'a'] * hp[m-j]) % p;
            resq = (resq + k[s[j]-'a'] * hq[m-j]) % q;
        }
        bool ans = se.count(resp * resq);
        rep(j,m-1){
            ll y = resp - k[s[j]-'a'] * hp[m-j] - k[s[j+1]-'a'] * hp[m-(j+1)] + k[s[j]-'a'] * hp[m-(j+1)] + k[s[j+1]-'a'] * hp[m-j];
            ll z = resq - k[s[j]-'a'] * hq[m-j] - k[s[j+1]-'a'] * hq[m-(j+1)] + k[s[j]-'a'] * hq[m-(j+1)] + k[s[j+1]-'a'] * hq[m-j];
            y = (y % p + p) % p;
            z = (z % q + q) % q;
            ans = ans + se.count(y*z);
        }
        se.insert(resp * resq);
        cout << (ans?"Yes\n":"No\n");
    }
    return 0;
}
0