結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 TLE -
testcase_02 WA -
testcase_03 WA -
testcase_04 TLE -
testcase_05 TLE -
testcase_06 TLE -
testcase_07 TLE -
testcase_08 WA -
testcase_09 TLE -
testcase_10 TLE -
testcase_11 TLE -
testcase_12 TLE -
testcase_13 WA -
testcase_14 TLE -
testcase_15 WA -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 TLE -
testcase_21 WA -
testcase_22 WA -
testcase_23 TLE -
権限があれば一括ダウンロードができます

ソースコード

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 = 1083;

const lint MOD = 998244353;
const 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]);
                    fflush(stdout);
                    return 0;
                }
            }
        }
    }

    return 0;
}
// *U*WQ
0