結果
問題 | No.2102 [Cherry Alpha *] Conditional Reflection |
ユーザー | 🍮かんプリン |
提出日時 | 2022-10-18 00:33:12 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 545 ms / 3,000 ms |
コード長 | 3,001 bytes |
コンパイル時間 | 1,841 ms |
コンパイル使用メモリ | 179,792 KB |
実行使用メモリ | 20,084 KB |
最終ジャッジ日時 | 2024-06-28 13:05:33 |
合計ジャッジ時間 | 28,184 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 3 ms
5,376 KB |
testcase_02 | AC | 310 ms
8,080 KB |
testcase_03 | AC | 361 ms
8,268 KB |
testcase_04 | AC | 323 ms
8,076 KB |
testcase_05 | AC | 280 ms
5,632 KB |
testcase_06 | AC | 377 ms
8,076 KB |
testcase_07 | AC | 195 ms
5,776 KB |
testcase_08 | AC | 171 ms
5,376 KB |
testcase_09 | AC | 272 ms
7,948 KB |
testcase_10 | AC | 185 ms
5,376 KB |
testcase_11 | AC | 114 ms
5,632 KB |
testcase_12 | AC | 243 ms
6,544 KB |
testcase_13 | AC | 366 ms
8,580 KB |
testcase_14 | AC | 290 ms
6,164 KB |
testcase_15 | AC | 387 ms
8,080 KB |
testcase_16 | AC | 523 ms
9,476 KB |
testcase_17 | AC | 146 ms
5,760 KB |
testcase_18 | AC | 284 ms
6,548 KB |
testcase_19 | AC | 209 ms
5,776 KB |
testcase_20 | AC | 401 ms
8,960 KB |
testcase_21 | AC | 278 ms
5,376 KB |
testcase_22 | AC | 528 ms
9,856 KB |
testcase_23 | AC | 501 ms
9,728 KB |
testcase_24 | AC | 516 ms
9,856 KB |
testcase_25 | AC | 517 ms
9,856 KB |
testcase_26 | AC | 525 ms
9,856 KB |
testcase_27 | AC | 488 ms
9,852 KB |
testcase_28 | AC | 513 ms
9,856 KB |
testcase_29 | AC | 533 ms
9,856 KB |
testcase_30 | AC | 518 ms
9,856 KB |
testcase_31 | AC | 506 ms
9,860 KB |
testcase_32 | AC | 545 ms
9,852 KB |
testcase_33 | AC | 507 ms
9,852 KB |
testcase_34 | AC | 508 ms
9,856 KB |
testcase_35 | AC | 502 ms
9,980 KB |
testcase_36 | AC | 489 ms
9,856 KB |
testcase_37 | AC | 491 ms
9,856 KB |
testcase_38 | AC | 479 ms
9,728 KB |
testcase_39 | AC | 486 ms
9,728 KB |
testcase_40 | AC | 479 ms
9,856 KB |
testcase_41 | AC | 489 ms
9,856 KB |
testcase_42 | AC | 330 ms
8,188 KB |
testcase_43 | AC | 338 ms
8,324 KB |
testcase_44 | AC | 326 ms
8,192 KB |
testcase_45 | AC | 328 ms
8,324 KB |
testcase_46 | AC | 330 ms
8,188 KB |
testcase_47 | AC | 230 ms
6,156 KB |
testcase_48 | AC | 248 ms
6,284 KB |
testcase_49 | AC | 250 ms
6,156 KB |
testcase_50 | AC | 239 ms
6,152 KB |
testcase_51 | AC | 234 ms
6,156 KB |
testcase_52 | AC | 70 ms
19,996 KB |
testcase_53 | AC | 69 ms
20,072 KB |
testcase_54 | AC | 68 ms
20,084 KB |
testcase_55 | AC | 97 ms
5,376 KB |
testcase_56 | AC | 98 ms
5,376 KB |
testcase_57 | AC | 96 ms
5,376 KB |
testcase_58 | AC | 75 ms
12,620 KB |
testcase_59 | AC | 544 ms
12,672 KB |
testcase_60 | AC | 167 ms
5,376 KB |
testcase_61 | AC | 96 ms
5,376 KB |
testcase_62 | AC | 12 ms
5,376 KB |
testcase_63 | AC | 105 ms
5,376 KB |
testcase_64 | AC | 106 ms
5,376 KB |
testcase_65 | AC | 109 ms
5,376 KB |
testcase_66 | AC | 92 ms
5,376 KB |
testcase_67 | AC | 322 ms
5,376 KB |
testcase_68 | AC | 83 ms
5,376 KB |
testcase_69 | AC | 321 ms
5,376 KB |
ソースコード
/** * @FileName a.cpp * @Author kanpurin * @Created 2022.10.18 00:32:53 **/ #include "bits/stdc++.h" using namespace std; typedef long long ll; using ull = unsigned long long; static const ull _mod = 0x1fffffffffffffff; mt19937_64 mt{(unsigned int)time(NULL)}; const ull _base = mt() % _mod; struct RollingHash { private: vector<ull> hashed, power; inline ull _mul(ull a, ull b) const { ull au = a >> 31; ull ad = a & ((1UL << 31) - 1); ull bu = b >> 31; ull bd = b & ((1UL << 31) - 1); ull mid = ad * bu + au * bd; ull midu = mid >> 30; ull midd = mid & ((1UL << 30) - 1); ull ans = au * bu * 2 + midu + (midd << 31) + ad * bd; ans = (ans >> 61) + (ans & _mod); if (ans >= _mod) ans -= _mod; return ans; } public: RollingHash(const string &s) { ll n = s.size(); hashed.assign(n + 1, 0); power.assign(n + 1, 0); power[0] = 1; for(ll i = 0; i < n; 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; } } ull get(ll l, ll r) const { ull ret = hashed[r] + _mod - _mul(hashed[l], power[r - l]); if(ret >= _mod) ret -= _mod; return ret; } ull connect(ull h1, ull h2, ll h2len) const { ull ret = _mul(h1, power[h2len]) + h2; if(ret >= _mod) ret -= _mod; return ret; } void connect(const string &s) { ll n = hashed.size() - 1, m = s.size(); hashed.resize(n + m + 1); power.resize(n + m + 1); for(ll i = n; i < n + m; i++) { power[i + 1] = _mul(power[i], _base); hashed[i + 1] = _mul(hashed[i], _base) + s[i - n]; if(hashed[i + 1] >= _mod) hashed[i + 1] -= _mod; } } ll LCP(const RollingHash &b, ll l1, ll r1, ll l2, ll r2) { ll len = min(r1 - l1, r2 - l2); ll low = -1, high = len + 1; while(high - low > 1) { ll mid = (low + high) / 2; if(get(l1, l1 + mid) == b.get(l2, l2 + mid)) low = mid; else high = mid; } return low; } }; int main() { int n;cin >> n; unordered_set<unsigned long long> st; for (int i = 0; i < n; i++) { string s;cin >> s; int m = s.size(); RollingHash rh(s); bool yes = false; if (st.count(rh.get(0,m))) { puts("Yes"); yes = true; } for (int j = 0; j <= m-2 && !yes; j++) { auto t = rh.connect(rh.get(0,j),rh.get(j+1,j+2),1); t = rh.connect(t,rh.get(j,j+1),1); t = rh.connect(t,rh.get(j+2,m),m-j-2); if (st.count(t)) { puts("Yes"); yes = true; } } if (!yes) puts("No"); st.insert(rh.get(0,m)); } return 0; }