結果

問題 No.3051 cracked
ユーザー furafura
提出日時 2023-09-15 23:37:58
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 386 ms / 1,024 ms
コード長 1,065 bytes
コンパイル時間 521 ms
コンパイル使用メモリ 66,072 KB
実行使用メモリ 24,408 KB
平均クエリ数 3.00
最終ジャッジ日時 2023-09-15 23:38:11
合計ジャッジ時間 11,769 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 378 ms
23,544 KB
testcase_01 AC 351 ms
23,676 KB
testcase_02 AC 356 ms
23,640 KB
testcase_03 AC 380 ms
23,412 KB
testcase_04 AC 357 ms
24,060 KB
testcase_05 AC 351 ms
24,408 KB
testcase_06 AC 377 ms
24,012 KB
testcase_07 AC 353 ms
24,372 KB
testcase_08 AC 349 ms
24,000 KB
testcase_09 AC 386 ms
23,652 KB
testcase_10 AC 356 ms
23,388 KB
testcase_11 AC 348 ms
23,640 KB
testcase_12 AC 386 ms
23,700 KB
testcase_13 AC 362 ms
23,376 KB
testcase_14 AC 356 ms
24,024 KB
testcase_15 AC 383 ms
24,024 KB
testcase_16 AC 352 ms
23,640 KB
testcase_17 AC 356 ms
23,844 KB
testcase_18 AC 379 ms
23,412 KB
testcase_19 AC 353 ms
23,400 KB
testcase_20 AC 352 ms
23,580 KB
testcase_21 AC 383 ms
23,664 KB
testcase_22 AC 357 ms
23,532 KB
testcase_23 AC 350 ms
24,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <string>

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

using namespace std;
using lint = long long;

constexpr int SIZE = 1065;

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

lint rolling_hash(const string& s) {
    lint h = 0;
    rep (i, SIZE) {
        if (32 <= s[i] and s[i] <= 126) {
            h = (h + BASE_POW[SIZE - i - 1] * (s[i] - 32)) % 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 (32 <= s[i] and s[i] <= 126) {
            for (char c = 32; 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;
}
// $?Q<D
0