結果

問題 No.469 区間加算と一致検索の問題
ユーザー PachicobuePachicobue
提出日時 2017-12-30 23:14:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,238 bytes
コンパイル時間 2,435 ms
コンパイル使用メモリ 208,408 KB
実行使用メモリ 16,840 KB
最終ジャッジ日時 2023-08-23 11:10:55
合計ジャッジ時間 7,935 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 3 ms
4,380 KB
testcase_03 AC 5 ms
4,384 KB
testcase_04 AC 6 ms
4,376 KB
testcase_05 AC 6 ms
4,376 KB
testcase_06 AC 7 ms
4,380 KB
testcase_07 AC 7 ms
4,376 KB
testcase_08 AC 8 ms
4,376 KB
testcase_09 AC 4 ms
4,380 KB
testcase_10 AC 6 ms
4,376 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 8 ms
4,380 KB
testcase_13 AC 5 ms
4,376 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 8 ms
4,376 KB
testcase_17 AC 6 ms
4,376 KB
testcase_18 AC 7 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 8 ms
4,376 KB
testcase_21 AC 3 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 WA -
testcase_24 AC 43 ms
5,988 KB
testcase_25 AC 44 ms
6,260 KB
testcase_26 AC 44 ms
5,932 KB
testcase_27 AC 44 ms
6,336 KB
testcase_28 WA -
testcase_29 AC 45 ms
5,968 KB
testcase_30 AC 44 ms
6,244 KB
testcase_31 AC 44 ms
6,248 KB
testcase_32 AC 44 ms
6,276 KB
testcase_33 AC 111 ms
16,548 KB
testcase_34 AC 125 ms
16,840 KB
testcase_35 AC 111 ms
16,408 KB
testcase_36 WA -
testcase_37 AC 122 ms
16,576 KB
testcase_38 AC 102 ms
15,060 KB
testcase_39 AC 102 ms
14,980 KB
testcase_40 WA -
testcase_41 AC 105 ms
15,132 KB
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 109 ms
15,132 KB
testcase_45 WA -
testcase_46 AC 104 ms
14,988 KB
testcase_47 WA -
testcase_48 AC 1 ms
4,376 KB
testcase_49 AC 2 ms
4,376 KB
testcase_50 AC 101 ms
15,016 KB
testcase_51 AC 101 ms
15,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

constexpr ll MOD = (ll)1e9 + 7LL;


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, Q;
    cin >> N >> Q;
    mt19937 mt{random_device{}()};
    uniform_int_distribution<ll> dist{2, MOD - 1};
    const ll base = dist(mt);
    vector<ll> value(N, 1);
    for (int i = 1; i < N; i++) {
        value[i] = value[i - 1] * base;
        value[i] %= MOD;
    }
    ll x = 0;
    map<ll, int> hash;
    for (int q = 0; q < Q; q++) {
        char c;
        cin >> c;
        if (c == '!') {
            int l, r;
            ll v;
            cin >> l >> r >> v;
            const ll add = ((r == N ? 0LL : value[r] * ((MOD - v) % MOD)) + value[l] * ((MOD + v) % MOD)) % MOD;
            x = (x + add) % MOD;
            if (hash.find(x) == hash.end()) {
                hash[x] = q + 1;
            }
        } else {
            cout << hash[x] << endl;
        }
    }

    return 0;
}
0