結果

問題 No.3051 cracked
ユーザー furafura
提出日時 2023-09-15 23:00:42
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,060 bytes
コンパイル時間 2,801 ms
コンパイル使用メモリ 243,668 KB
実行使用メモリ 24,456 KB
平均クエリ数 1.00
最終ジャッジ日時 2023-09-15 23:00:52
合計ジャッジ時間 7,863 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
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 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
using lint = long long;

constexpr int SIZE = 1054;

constexpr lint MOD = 998244353;
constexpr lint BASE = 126 - 33 + 1;
lint BASE_POW[SIZE];

lint rolling_hash(const string& s) {
    lint h = 0;
    rep (i, SIZE) {
        if (33 <= s[i] and s[i] <= 126) {
            h = (h + BASE_POW[SIZE - i - 1] * (s[i] - 33)) % MOD;
        }
    }
    return h;
}

int main() {
    BASE_POW[0] = 1;
    rep (i, SIZE - 1) BASE_POW[i + 1] = BASE_POW[i] * BASE % MOD;

    string s;
    rep (_, SIZE) s += getchar();

    lint h = rolling_hash(s);
    rep (i, SIZE) {
        if (33 <= s[i] and s[i] <= 126) {
            for (char c = 33; c <= 126; c++) {
                lint h2 = (h + BASE_POW[SIZE - i - 1] * (c - s[i])) % MOD;
                if (h2 < 0) h2 += MOD;
                if (h2 == 0) {
                    // printf("%d\n\"%c\"\n\"%c\"\n", i, c, s[i]);
                    // return 0;
                }
            }
        }
    }

    return 0;
}
// !tgIN
0