結果
問題 | No.2102 [Cherry Alpha *] Conditional Reflection |
ユーザー | 👑 emthrm |
提出日時 | 2022-10-14 21:52:50 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,202 bytes |
コンパイル時間 | 2,444 ms |
コンパイル使用メモリ | 216,840 KB |
実行使用メモリ | 65,944 KB |
最終ジャッジ日時 | 2024-06-26 13:47:19 |
合計ジャッジ時間 | 52,470 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,944 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 173 ms
10,240 KB |
testcase_06 | WA | - |
testcase_07 | AC | 795 ms
44,032 KB |
testcase_08 | AC | 43 ms
6,944 KB |
testcase_09 | WA | - |
testcase_10 | AC | 105 ms
7,936 KB |
testcase_11 | AC | 145 ms
14,208 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | AC | 447 ms
29,824 KB |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | AC | 80 ms
6,940 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 | 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 | WA | - |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | AC | 665 ms
17,024 KB |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | WA | - |
testcase_50 | WA | - |
testcase_51 | WA | - |
testcase_52 | AC | 1,010 ms
65,876 KB |
testcase_53 | AC | 1,016 ms
65,900 KB |
testcase_54 | AC | 995 ms
65,944 KB |
testcase_55 | WA | - |
testcase_56 | WA | - |
testcase_57 | AC | 998 ms
48,512 KB |
testcase_58 | AC | 76 ms
12,160 KB |
testcase_59 | WA | - |
testcase_60 | AC | 42 ms
6,940 KB |
testcase_61 | AC | 1,034 ms
48,512 KB |
testcase_62 | AC | 9 ms
6,940 KB |
testcase_63 | AC | 155 ms
6,944 KB |
testcase_64 | AC | 144 ms
6,940 KB |
testcase_65 | AC | 180 ms
6,944 KB |
testcase_66 | WA | - |
testcase_67 | AC | 109 ms
6,944 KB |
testcase_68 | AC | 83 ms
6,940 KB |
testcase_69 | AC | 103 ms
6,944 KB |
ソースコード
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; #define FOR(i,m,n) for(int i=(m);i<(n);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() using ll = long long; constexpr int INF = 0x3f3f3f3f; constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL; constexpr double EPS = 1e-8; constexpr int MOD = 998244353; // constexpr int MOD = 1000000007; constexpr int DY4[]{1, 0, -1, 0}, DX4[]{0, -1, 0, 1}; constexpr int DY8[]{1, 1, 0, -1, -1, -1, 0, 1}; constexpr int DX8[]{0, -1, -1, -1, 0, 1, 1, 1}; template <typename T, typename U> inline bool chmax(T& a, U b) { return a < b ? (a = b, true) : false; } template <typename T, typename U> inline bool chmin(T& a, U b) { return a > b ? (a = b, true) : false; } struct IOSetup { IOSetup() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << fixed << setprecision(20); } } iosetup; template <typename T = std::string> struct RollingHash { T s; explicit RollingHash(const T& s, const int base = 10007, const int mod = 1000000007) : base(base), mod(mod), hash({0}), power({1}) { const int n = s.size(); this->s.reserve(n); hash.reserve(n + 1); power.reserve(n + 1); add(s); } long long get(const int left, const int right) const { const long long res = hash[right] - hash[left] * power[right - left] % mod; return res < 0 ? res + mod : res; } void add(const T& t) { for (const auto c : t) { s.push_back(c); const int hash_nxt = (hash.back() * base % mod + c) % mod; hash.emplace_back(hash_nxt); const int power_nxt = power.back() * base % mod; power.emplace_back(power_nxt); } } int longest_common_prefix(const int i, const int j) const { const int n = s.size(); int lb = 0, ub = n + 1 - std::max(i, j); while (ub - lb > 1) { const int mid = (lb + ub) >> 1; (get(i, i + mid) == get(j, j + mid) ? lb : ub) = mid; } return lb; } template <typename U> int longest_common_prefix(const RollingHash<U>& t, const int i, const int j) const { int lb = 0; int ub = std::min(static_cast<int>(s.size()) - i, static_cast<int>(t.s.size()) - j) + 1; while (ub - lb > 1) { const int mid = (lb + ub) >> 1; (get(i, i + mid) == t.get(j, j + mid) ? lb : ub) = mid; } return lb; } std::vector<long long> power; private: const int base, mod; std::vector<long long> hash; }; int main() { int n; cin >> n; map<int, set<int>> hashes; while (n--) { string s; cin >> s; RollingHash rolling_hash(s, 10007, MOD); const int l = s.length(), hash = rolling_hash.get(0, l); cout << (hashes[l].count(hash) ? "Yes\n" : "No\n"); hashes[l].emplace(hash); FOR(i, 1, l) { ll nhash = hash; nhash -= 1LL * rolling_hash.power[l - 1 - (i - 1)] * s[i - 1]; nhash -= 1LL * rolling_hash.power[l - 1 - i] * s[i]; nhash += 1LL * rolling_hash.power[l - 1 - (i - 1)] * s[i]; nhash += 1LL * rolling_hash.power[l - 1 - i] * s[i - 1]; hashes[l].emplace((nhash % MOD + MOD) % MOD); } } return 0; }