結果
問題 | No.2102 [Cherry Alpha *] Conditional Reflection |
ユーザー | 🍮かんプリン |
提出日時 | 2022-10-17 23:59:33 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,008 bytes |
コンパイル時間 | 2,030 ms |
コンパイル使用メモリ | 178,636 KB |
実行使用メモリ | 20,108 KB |
最終ジャッジ日時 | 2024-06-28 12:44:53 |
合計ジャッジ時間 | 42,824 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 551 ms
7,952 KB |
testcase_03 | AC | 595 ms
8,192 KB |
testcase_04 | WA | - |
testcase_05 | AC | 531 ms
5,504 KB |
testcase_06 | WA | - |
testcase_07 | AC | 276 ms
5,656 KB |
testcase_08 | WA | - |
testcase_09 | AC | 483 ms
7,952 KB |
testcase_10 | WA | - |
testcase_11 | AC | 191 ms
5,504 KB |
testcase_12 | AC | 448 ms
6,548 KB |
testcase_13 | WA | - |
testcase_14 | AC | 534 ms
6,156 KB |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | AC | 207 ms
5,504 KB |
testcase_18 | WA | - |
testcase_19 | AC | 356 ms
5,520 KB |
testcase_20 | WA | - |
testcase_21 | AC | 535 ms
5,376 KB |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | AC | 837 ms
9,856 KB |
testcase_30 | AC | 866 ms
9,856 KB |
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 | AC | 849 ms
9,856 KB |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | AC | 527 ms
8,068 KB |
testcase_43 | AC | 537 ms
8,128 KB |
testcase_44 | AC | 536 ms
8,068 KB |
testcase_45 | AC | 551 ms
8,064 KB |
testcase_46 | AC | 521 ms
8,064 KB |
testcase_47 | AC | 352 ms
6,032 KB |
testcase_48 | AC | 340 ms
6,152 KB |
testcase_49 | AC | 344 ms
6,028 KB |
testcase_50 | AC | 352 ms
6,152 KB |
testcase_51 | AC | 341 ms
6,028 KB |
testcase_52 | AC | 72 ms
19,984 KB |
testcase_53 | AC | 72 ms
19,988 KB |
testcase_54 | AC | 73 ms
20,108 KB |
testcase_55 | AC | 99 ms
5,376 KB |
testcase_56 | AC | 100 ms
5,376 KB |
testcase_57 | AC | 99 ms
5,376 KB |
testcase_58 | AC | 78 ms
12,492 KB |
testcase_59 | WA | - |
testcase_60 | AC | 311 ms
5,376 KB |
testcase_61 | AC | 100 ms
5,376 KB |
testcase_62 | AC | 19 ms
5,376 KB |
testcase_63 | AC | 175 ms
5,376 KB |
testcase_64 | AC | 174 ms
5,376 KB |
testcase_65 | AC | 180 ms
5,376 KB |
testcase_66 | AC | 96 ms
5,376 KB |
testcase_67 | AC | 599 ms
5,376 KB |
testcase_68 | WA | - |
testcase_69 | AC | 599 ms
5,376 KB |
ソースコード
/** * @FileName a.cpp * @Author kanpurin * @Created 2022.10.17 23:59:00 **/ #include "bits/stdc++.h" using namespace std; typedef long long ll; struct RollingHash { private: using ull = unsigned long long; const ull _mod = 0x1fffffffffffffff; mt19937_64 mt{(unsigned int)time(NULL)}; const ull _base = mt() % _mod; 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; }