結果

問題 No.2102 [Cherry Alpha *] Conditional Reflection
ユーザー dyktr_06dyktr_06
提出日時 2022-10-14 23:23:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,724 bytes
コンパイル時間 2,003 ms
コンパイル使用メモリ 180,716 KB
実行使用メモリ 21,664 KB
最終ジャッジ日時 2023-09-08 23:47:03
合計ジャッジ時間 20,300 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 195 ms
9,480 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 121 ms
7,688 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
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 274 ms
13,448 KB
testcase_43 AC 274 ms
13,520 KB
testcase_44 AC 279 ms
13,508 KB
testcase_45 AC 276 ms
13,500 KB
testcase_46 AC 272 ms
13,504 KB
testcase_47 AC 227 ms
9,328 KB
testcase_48 AC 227 ms
9,204 KB
testcase_49 AC 236 ms
9,172 KB
testcase_50 AC 226 ms
9,300 KB
testcase_51 AC 227 ms
9,276 KB
testcase_52 AC 45 ms
19,704 KB
testcase_53 AC 45 ms
19,760 KB
testcase_54 AC 46 ms
19,712 KB
testcase_55 AC 93 ms
5,100 KB
testcase_56 AC 93 ms
5,260 KB
testcase_57 AC 93 ms
5,088 KB
testcase_58 AC 41 ms
12,000 KB
testcase_59 WA -
testcase_60 WA -
testcase_61 AC 93 ms
5,192 KB
testcase_62 AC 5 ms
4,380 KB
testcase_63 WA -
testcase_64 AC 44 ms
10,168 KB
testcase_65 WA -
testcase_66 AC 88 ms
5,196 KB
testcase_67 AC 51 ms
15,480 KB
testcase_68 AC 42 ms
5,088 KB
testcase_69 AC 51 ms
15,492 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘void in(T& ...)’ 内:
main.cpp:28:55: 警告: fold-expressions only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   28 | template<class... T> void in(T&... a){ (cin >> ... >> a); }
      |                                                       ^
main.cpp: 関数 ‘void out(const T&, const Ts& ...)’ 内:
main.cpp:30:112: 警告: fold-expressions only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   30 | template<class T, class... Ts> void out(const T& a, const Ts&... b){ cout << a; (cout << ... << (cout << ' ', b)); cout << '\n'; }
      |                                                                                                                ^

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()
#define Sort(a) sort(a.begin(), a.end())
#define RSort(a) sort(a.rbegin(), a.rend())

typedef long long int ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<char> vc;
typedef vector<string> vst;
typedef vector<double> vd;
typedef pair<long long, long long> P;

const long long INF = 0x1fffffffffffffff;
const long long MOD = 998244353;
const long double PI = acos(-1);
 
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; }
template<class T, class U> inline T vin(T& vec, U n) { vec.resize(n); for(int i = 0; i < (int) n; ++i) cin >> vec[i]; return vec; }
template<class T> inline void vout(T vec, string s = "\n"){ for(auto x : vec) cout << x << s; }
template<class... T> void in(T&... a){ (cin >> ... >> a); }
void out(){ cout << '\n'; }
template<class T, class... Ts> void out(const T& a, const Ts&... b){ cout << a; (cout << ... << (cout << ' ', b)); cout << '\n'; }
template<class T, class U> void inGraph(vector<vector<T>>& G, U n, U m, bool directed = false){ G.resize(n); for(int i = 0; i < m; i++){ int a, b; cin >> a >> b; a--, b--; G[a].push_back(b); if(!directed) G[b].push_back(a); } }

struct RollingHash{
    vector<unsigned long> hashed, power;
    static constexpr unsigned long mod = (1uL << 61) - 1;
	
    unsigned long mul(__int128_t a, __int128_t b) const {
		__int128_t t = a * b;
		t = (t >> 61) + (t & mod);
		
		if(t >= mod) return t - mod;
		return t;
	}

    RollingHash(const string &s, unsigned base = 10007){
        int siz = (int) s.size();
        hashed.assign(siz + 1, 0);
        power.assign(siz + 1, 0);
        power[0] = 1;
        for(int i = 0; i < siz; i++){
            power[i + 1] = mul(power[i], base);
            hashed[i + 1] = mul(hashed[i], base) + s[i];
            if(hashed[i + 1] >= mod) hashed[i + 1] -= mod;
        }
    }

    unsigned long get(int l, int r) const {
        unsigned long ret = hashed[r] + mod - mul(hashed[l], power[r - l]);
        if(ret >= mod) ret -= mod;
        return ret;
    }

    unsigned long connect(unsigned long h1, unsigned long h2, int h2len) const {
        unsigned long ret = mul(h1, power[h2len]) + h2;
        if(ret >= mod) ret -= mod;
        return ret;
    }

    int LCP(const RollingHash &b, int l1, int r1, int l2, int r2){
        int len = min(r1 - l1, r2 - l2);
        int low = -1, high = len + 1;
        while(high - low > 1){
            int mid = (low + high) / 2;
            if(get(l1, l1 + mid) == b.get(l2, l2 + mid)) low = mid;
            else high = mid;
        }
        return low;
    }
};

ll n;
vst s;

void input(){
    in(n);
    vin(s, n);
}
 
void solve(){
    map<unsigned long, ll> mp;
    rep(i, n){
        string ans = "No";
        RollingHash rh(s[i]);
        ll m = s[i].size();
        rep(j, m - 1){
            ll hashed = rh.get(0, j);
            ll a = rh.get(j, j + 1), b = rh.get(j + 1, j + 2);
            hashed = rh.connect(hashed, b, 1);
            hashed = rh.connect(hashed, a, 1);
            if(j != m - 2){
                ll c = rh.get(j + 2, m);
                hashed = rh.connect(hashed, c, m - j - 2);
            }
            if(mp.count(hashed) != 0){
                ans = "Yes";
                break;
            }
        }
        mp[rh.get(0, m)] = 1;
        out(ans);
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    input();
    solve();
}
0