結果

問題 No.2102 [Cherry Alpha *] Conditional Reflection
ユーザー milanis48663220milanis48663220
提出日時 2022-10-14 23:28:24
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 880 ms / 3,000 ms
コード長 2,816 bytes
コンパイル時間 1,288 ms
コンパイル使用メモリ 125,016 KB
実行使用メモリ 29,740 KB
最終ジャッジ日時 2023-09-08 23:54:46
合計ジャッジ時間 36,695 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
11,328 KB
testcase_01 AC 15 ms
11,148 KB
testcase_02 AC 438 ms
19,616 KB
testcase_03 AC 531 ms
22,180 KB
testcase_04 AC 460 ms
19,368 KB
testcase_05 AC 346 ms
15,592 KB
testcase_06 AC 491 ms
20,012 KB
testcase_07 AC 304 ms
16,140 KB
testcase_08 AC 182 ms
11,900 KB
testcase_09 AC 424 ms
21,040 KB
testcase_10 AC 242 ms
14,280 KB
testcase_11 AC 171 ms
15,484 KB
testcase_12 AC 350 ms
18,644 KB
testcase_13 AC 584 ms
23,228 KB
testcase_14 AC 393 ms
17,548 KB
testcase_15 AC 557 ms
20,400 KB
testcase_16 AC 741 ms
25,260 KB
testcase_17 AC 209 ms
15,164 KB
testcase_18 AC 393 ms
18,904 KB
testcase_19 AC 275 ms
16,152 KB
testcase_20 AC 629 ms
24,040 KB
testcase_21 AC 306 ms
12,356 KB
testcase_22 AC 803 ms
26,664 KB
testcase_23 AC 804 ms
26,816 KB
testcase_24 AC 805 ms
26,800 KB
testcase_25 AC 809 ms
26,736 KB
testcase_26 AC 797 ms
26,940 KB
testcase_27 AC 807 ms
26,884 KB
testcase_28 AC 787 ms
26,632 KB
testcase_29 AC 799 ms
26,756 KB
testcase_30 AC 778 ms
26,636 KB
testcase_31 AC 785 ms
26,696 KB
testcase_32 AC 803 ms
26,716 KB
testcase_33 AC 808 ms
26,748 KB
testcase_34 AC 788 ms
26,776 KB
testcase_35 AC 792 ms
26,864 KB
testcase_36 AC 795 ms
26,756 KB
testcase_37 AC 779 ms
26,652 KB
testcase_38 AC 779 ms
26,864 KB
testcase_39 AC 787 ms
26,668 KB
testcase_40 AC 797 ms
26,980 KB
testcase_41 AC 787 ms
26,756 KB
testcase_42 AC 517 ms
21,676 KB
testcase_43 AC 531 ms
21,592 KB
testcase_44 AC 549 ms
21,544 KB
testcase_45 AC 549 ms
21,592 KB
testcase_46 AC 549 ms
21,572 KB
testcase_47 AC 376 ms
17,692 KB
testcase_48 AC 368 ms
17,536 KB
testcase_49 AC 374 ms
17,404 KB
testcase_50 AC 373 ms
17,556 KB
testcase_51 AC 387 ms
17,440 KB
testcase_52 AC 26 ms
11,912 KB
testcase_53 AC 26 ms
11,920 KB
testcase_54 AC 26 ms
11,868 KB
testcase_55 AC 90 ms
11,228 KB
testcase_56 AC 91 ms
11,280 KB
testcase_57 AC 89 ms
11,576 KB
testcase_58 AC 27 ms
11,840 KB
testcase_59 AC 880 ms
29,740 KB
testcase_60 AC 164 ms
11,444 KB
testcase_61 AC 91 ms
11,300 KB
testcase_62 AC 26 ms
11,680 KB
testcase_63 AC 96 ms
11,200 KB
testcase_64 AC 94 ms
11,468 KB
testcase_65 AC 109 ms
11,320 KB
testcase_66 AC 86 ms
11,292 KB
testcase_67 AC 294 ms
11,104 KB
testcase_68 AC 34 ms
11,572 KB
testcase_69 AC 298 ms
11,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>
#include <atcoder/modint>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
typedef long long ll;

template<typename T>
vector<vector<T>> vec2d(int n, int m, T v){
    return vector<vector<T>>(n, vector<T>(m, v));
}

template<typename T>
vector<vector<vector<T>>> vec3d(int n, int m, int k, T v){
    return vector<vector<vector<T>>>(n, vector<vector<T>>(m, vector<T>(k, v)));
}

template<typename T>
void print_vector(vector<T> v, char delimiter=' '){
    if(v.empty()) {
        cout << endl;
        return;
    }
    for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter;
    cout << v.back() << endl;
}

using mint = atcoder::modint998244353;
using mint1 = atcoder::modint1000000007;
int p = 10007;
const int N = 1000000;

mint pw[N+1];
mint1 pw1[N+1];

void init(){
    pw[0] = 1;
    pw1[0] = 1;
    for(int i = 1; i <= N; i++) pw[i] = pw[i-1]*p;
    for(int i = 1; i <= N; i++) pw1[i] = pw1[i-1]*p;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    init();
    int n; cin >> n;
    set<int> st;
    set<int> st1;
    for(int i = 0; i < n; i++){
        string s; cin >> s;
        mint h = 0;
        mint1 h1 = 0;
        int m = s.size();
        for(int j = 0; j < m; j++){
            h += pw[j]*(s[j]-'a'+1);
            h1 += pw1[j]*(s[j]-'a'+1);
        }
        bool ok = false;
        if(st.count(h.val()) > 0 && st1.count(h1.val())){
            ok = true;
        }else{
            for(int j = 0; j+1 < m; j++){
                mint new_h = h;
                new_h += pw[j]*((s[j+1]-'a'+1)-(s[j]-'a'+1));
                new_h += pw[j+1]*((s[j]-'a'+1)-(s[j+1]-'a'+1));
                if(st.count(new_h.val()) == 0){
                    continue;
                }
                mint1 new_h1 = h1;
                new_h1 += pw1[j]*((s[j+1]-'a'+1)-(s[j]-'a'+1));
                new_h1 += pw1[j+1]*((s[j]-'a'+1)-(s[j+1]-'a'+1));
                if(st1.count(new_h1.val()) == 0){
                    continue;
                }
                ok = true;
                break;
            }
        }

        st.insert(h.val());
        st1.insert(h1.val());
        if(ok) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}
0