結果

問題 No.2102 [Cherry Alpha *] Conditional Reflection
ユーザー ruthenruthen
提出日時 2022-10-15 00:03:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 555 ms / 3,000 ms
コード長 1,702 bytes
コンパイル時間 2,888 ms
コンパイル使用メモリ 213,828 KB
実行使用メモリ 19,896 KB
最終ジャッジ日時 2023-09-09 01:00:41
合計ジャッジ時間 23,917 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 199 ms
7,664 KB
testcase_03 AC 262 ms
8,720 KB
testcase_04 AC 212 ms
7,368 KB
testcase_05 AC 131 ms
5,736 KB
testcase_06 AC 221 ms
7,740 KB
testcase_07 AC 203 ms
5,848 KB
testcase_08 AC 40 ms
4,380 KB
testcase_09 AC 229 ms
8,172 KB
testcase_10 AC 81 ms
4,992 KB
testcase_11 AC 74 ms
5,584 KB
testcase_12 AC 162 ms
7,068 KB
testcase_13 AC 308 ms
9,396 KB
testcase_14 AC 165 ms
6,688 KB
testcase_15 AC 246 ms
7,948 KB
testcase_16 AC 374 ms
10,348 KB
testcase_17 AC 130 ms
5,376 KB
testcase_18 AC 242 ms
7,076 KB
testcase_19 AC 109 ms
5,896 KB
testcase_20 AC 323 ms
9,708 KB
testcase_21 AC 76 ms
4,380 KB
testcase_22 AC 441 ms
11,008 KB
testcase_23 AC 423 ms
11,104 KB
testcase_24 AC 422 ms
11,304 KB
testcase_25 AC 478 ms
11,068 KB
testcase_26 AC 449 ms
11,136 KB
testcase_27 AC 454 ms
11,304 KB
testcase_28 AC 494 ms
11,188 KB
testcase_29 AC 555 ms
11,056 KB
testcase_30 AC 445 ms
11,256 KB
testcase_31 AC 445 ms
11,196 KB
testcase_32 AC 447 ms
11,056 KB
testcase_33 AC 456 ms
11,180 KB
testcase_34 AC 443 ms
11,080 KB
testcase_35 AC 437 ms
11,016 KB
testcase_36 AC 439 ms
11,104 KB
testcase_37 AC 431 ms
11,016 KB
testcase_38 AC 410 ms
11,192 KB
testcase_39 AC 412 ms
11,320 KB
testcase_40 AC 407 ms
11,076 KB
testcase_41 AC 421 ms
11,012 KB
testcase_42 AC 309 ms
8,512 KB
testcase_43 AC 317 ms
8,704 KB
testcase_44 AC 307 ms
8,520 KB
testcase_45 AC 311 ms
8,576 KB
testcase_46 AC 308 ms
8,584 KB
testcase_47 AC 242 ms
6,672 KB
testcase_48 AC 241 ms
6,384 KB
testcase_49 AC 239 ms
6,376 KB
testcase_50 AC 246 ms
6,488 KB
testcase_51 AC 244 ms
6,492 KB
testcase_52 AC 37 ms
19,820 KB
testcase_53 AC 38 ms
19,852 KB
testcase_54 AC 37 ms
19,896 KB
testcase_55 AC 90 ms
4,380 KB
testcase_56 AC 92 ms
4,380 KB
testcase_57 AC 91 ms
4,376 KB
testcase_58 AC 41 ms
11,788 KB
testcase_59 AC 441 ms
12,684 KB
testcase_60 AC 32 ms
4,380 KB
testcase_61 AC 91 ms
4,384 KB
testcase_62 AC 8 ms
4,376 KB
testcase_63 AC 89 ms
4,376 KB
testcase_64 AC 92 ms
4,376 KB
testcase_65 AC 129 ms
4,380 KB
testcase_66 AC 91 ms
4,380 KB
testcase_67 AC 69 ms
4,380 KB
testcase_68 AC 36 ms
4,380 KB
testcase_69 AC 66 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#ifdef _RUTHEN
#include <debug.hpp>
#else
#define show(...) true
#endif

using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
template <class T> using V = vector<T>;

#include <atcoder/modint>
using mint1 = atcoder::modint1000000007;
using mint2 = atcoder::modint998244353;
ostream &operator<<(ostream &os, const mint1 &p) { return os << p.val(); }
ostream &operator<<(ostream &os, const mint2 &p) { return os << p.val(); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    set<pair<unsigned int, unsigned int>> st;
    mint1 B1 = 100007;
    mint2 B2 = 100007;
    rep(i, N) {
        string S;
        cin >> S;
        int M = (int)S.size();
        V<mint1> h1(M + 1), p1(M + 1, 1);
        V<mint2> h2(M + 1), p2(M + 1, 1);
        rep(i, M) {
            h1[i + 1] = h1[i] * B1 + S[i];
            h2[i + 1] = h2[i] * B2 + S[i];
            p1[i + 1] = p1[i] * B1;
            p2[i + 1] = p2[i] * B2;
        }
        int seen = 0;
        if (st.find({h1[M].val(), h2[M].val()}) != st.end()) seen = 1;
        rep(i, M - 1) {
            mint1 ch1 = h1[M];
            ch1 -= h1[i + 2] * p1[M - 2 - i];
            ch1 += h1[i] * p1[M - i];
            ch1 += S[i + 1] * p1[M - i - 1] + S[i] * p1[M - 2 - i];
            mint2 ch2 = h2[M];
            ch2 -= h2[i + 2] * p2[M - 2 - i];
            ch2 += h2[i] * p2[M - i];
            ch2 += S[i + 1] * p2[M - i - 1] + S[i] * p2[M - 2 - i];
            if (st.find({ch1.val(), ch2.val()}) != st.end()) seen = 1;
        }
        cout << (seen ? "Yes" : "No") << '\n';
        st.insert({h1[M].val(), h2[M].val()});
    }
    return 0;
}
0