結果

問題 No.2102 [Cherry Alpha *] Conditional Reflection
ユーザー AngrySadEightAngrySadEight
提出日時 2022-10-15 00:39:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,927 bytes
コンパイル時間 4,329 ms
コンパイル使用メモリ 269,540 KB
実行使用メモリ 57,416 KB
最終ジャッジ日時 2023-09-09 01:23:24
合計ジャッジ時間 44,297 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
10,760 KB
testcase_01 AC 9 ms
10,804 KB
testcase_02 AC 419 ms
34,640 KB
testcase_03 AC 485 ms
38,456 KB
testcase_04 WA -
testcase_05 AC 314 ms
21,868 KB
testcase_06 AC 468 ms
35,532 KB
testcase_07 WA -
testcase_08 AC 180 ms
14,892 KB
testcase_09 WA -
testcase_10 AC 220 ms
19,112 KB
testcase_11 AC 181 ms
22,388 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 392 ms
26,036 KB
testcase_15 AC 564 ms
36,200 KB
testcase_16 WA -
testcase_17 AC 306 ms
36,124 KB
testcase_18 WA -
testcase_19 AC 256 ms
23,652 KB
testcase_20 WA -
testcase_21 AC 294 ms
17,728 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 AC 791 ms
56,284 KB
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 403 ms
26,328 KB
testcase_43 AC 389 ms
26,304 KB
testcase_44 AC 402 ms
26,340 KB
testcase_45 AC 411 ms
26,268 KB
testcase_46 AC 393 ms
26,368 KB
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 AC 482 ms
53,212 KB
testcase_53 AC 463 ms
53,364 KB
testcase_54 AC 463 ms
53,220 KB
testcase_55 AC 550 ms
54,204 KB
testcase_56 AC 557 ms
54,244 KB
testcase_57 AC 583 ms
54,476 KB
testcase_58 AC 72 ms
12,316 KB
testcase_59 AC 818 ms
57,416 KB
testcase_60 AC 173 ms
14,224 KB
testcase_61 AC 588 ms
54,312 KB
testcase_62 AC 21 ms
11,324 KB
testcase_63 AC 163 ms
15,020 KB
testcase_64 AC 160 ms
14,852 KB
testcase_65 AC 174 ms
15,048 KB
testcase_66 WA -
testcase_67 AC 336 ms
17,228 KB
testcase_68 AC 75 ms
12,952 KB
testcase_69 AC 336 ms
17,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n) - 1; i >= 0; i--)
#define repk(i, k, n) for (int i = k; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define mod1 1000000007
#define mod2 998244353
#define vi vector<int>
#define vs vector<string>
#define vc vector<char>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvc vector<vector<char>>
#define vvl vector<vector<ll>>
#define vvvi vector<vector<vector<int>>>
#define vvvl vector<vector<vector<ll>>>
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define vvpii vector<vector<pair<int,int>>>
#define vvpll vector<vector<pair<ll,ll>>>

template<typename T> void debug(T e){
    cerr << e << endl;
}

template<typename T> void debug(vector<T> &v){
    rep(i, v.size()){
        cerr << v[i] << " ";
    }
    cerr << endl;
}

template<typename T> void debug(vector<vector<T>> &v){
    rep(i, v.size()){
        rep(j, v[i].size()){
            cerr << v[i][j] << " ";
        }
        cerr << endl;
    }
}

template<typename T> void debug(vector<pair<T, T>> &v){
    rep(i,v.size()){
        cerr << v[i].first << " " << v[i].second << endl;
    }
}

template<typename T> void debug(set<T> &st){
    for (auto itr = st.begin(); itr != st.end(); itr++){
        cerr << *itr << " ";
    }
    cerr << endl;
}

template<typename T> void debug(multiset<T> &ms){
    for (auto itr = ms.begin(); itr != ms.end(); itr++){
        cerr << *itr << " ";
    }
    cerr << endl;
}

template<typename T> void debug(map<T, T> &mp){
    for (auto itr = mp.begin(); itr != mp.end(); itr++){
        cerr << itr->first << " " << itr->second << endl;
    }
}

void debug_out(){
    cerr << endl;
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T){
    cerr << H << " ";
    debug_out(T...);
}

ll mk_hash(string S, ll h, ll mod){
    ll num = 1;
    ll ret = 0;
    for (ll i = 0; i < S.size(); i++){
        ret = (ret * h) % mod;
        ret = (ret + (S[i] - 'a')) % mod;
    }
    return ret;
}

ll to_single_val(ll hashs, ll len){
    return hashs * 1000000 + len;
}

int main(){
    int N;
    cin >> N;
    vs S(N);
    unordered_map<ll, ll> mp;
    rep(i,N) cin >> S[i];
    ll h1 = 1009;
    for (ll i = 0; i < N; i++){
        ll hashs = mk_hash(S[i], h1, mod1);
        //debug(hashs);
        //mp[to_single_val(hashs, len)]++;
        //mp[pll(hashs, S[i].size())]++;
    }
    vl pows(1000002);
    pows[0] = 1;
    for (ll i = 0; i < 1000001; i++){
        pows[i + 1] = (pows[i] * h1) % mod1;
    }
    for (ll i = 0; i < N; i++){
        bool pos = false;
        ll hashs = mk_hash(S[i], h1, mod1);
        if (mp[to_single_val(hashs, S[i].size())]){
            pos = true;
        }
        ll len = S[i].size();
        for (ll j = 0; j < len - 1; j++){
            ll new_hash = hashs;
            new_hash = (new_hash - ((ll)(S[i][j] - 'a') * pows[len - 1 - j]) % mod1 + mod1) % mod1;
            new_hash = (new_hash + ((ll)(S[i][j + 1] - 'a') * pows[len - 1 - j]) % mod1 + mod1) % mod1;
            new_hash = (new_hash - ((ll)(S[i][j + 1] - 'a') * pows[len - 1 - (j + 1)]) % mod1 + mod1) % mod1;
            new_hash = (new_hash + ((ll)(S[i][j] - 'a') * pows[len - 1 - (j + 1)]) % mod1 + mod1) % mod1;
            //debug(new_hash);
            //debug(to_single_val(new_hash, S[i].size()));
            if (mp[to_single_val(new_hash, S[i].size())]){
                pos = true;
            }
            /*if (mp[pll(new_hash, S[i].size())]){
                pos = true;
            }*/
        }
        if (pos) cout << "Yes" << endl;
        else cout << "No" << endl;
        mp[to_single_val(hashs, S[i].size())]++;
    }
}
0