結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 3 ms
4,380 KB
testcase_03 AC 4 ms
4,380 KB
testcase_04 AC 5 ms
4,376 KB
testcase_05 AC 6 ms
4,380 KB
testcase_06 AC 7 ms
4,376 KB
testcase_07 AC 7 ms
4,380 KB
testcase_08 AC 8 ms
4,380 KB
testcase_09 AC 4 ms
4,380 KB
testcase_10 AC 5 ms
4,380 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 8 ms
4,376 KB
testcase_13 AC 5 ms
4,376 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 AC 4 ms
4,380 KB
testcase_16 AC 8 ms
4,376 KB
testcase_17 AC 7 ms
4,380 KB
testcase_18 AC 7 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 8 ms
4,380 KB
testcase_21 AC 3 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 44 ms
6,232 KB
testcase_24 AC 43 ms
6,304 KB
testcase_25 AC 43 ms
6,500 KB
testcase_26 AC 43 ms
6,212 KB
testcase_27 AC 43 ms
6,040 KB
testcase_28 AC 45 ms
6,056 KB
testcase_29 AC 43 ms
6,244 KB
testcase_30 AC 43 ms
6,020 KB
testcase_31 AC 43 ms
5,932 KB
testcase_32 AC 43 ms
6,048 KB
testcase_33 AC 114 ms
16,592 KB
testcase_34 AC 115 ms
16,548 KB
testcase_35 AC 120 ms
16,584 KB
testcase_36 AC 119 ms
16,352 KB
testcase_37 AC 115 ms
16,580 KB
testcase_38 AC 98 ms
15,004 KB
testcase_39 AC 99 ms
14,964 KB
testcase_40 AC 101 ms
15,084 KB
testcase_41 AC 101 ms
14,952 KB
testcase_42 AC 99 ms
15,024 KB
testcase_43 AC 103 ms
15,084 KB
testcase_44 WA -
testcase_45 AC 101 ms
15,020 KB
testcase_46 AC 98 ms
14,996 KB
testcase_47 WA -
testcase_48 AC 1 ms
4,376 KB
testcase_49 AC 1 ms
4,380 KB
testcase_50 AC 99 ms
14,968 KB
testcase_51 WA -
権限があれば一括ダウンロードができます

ソースコード

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 MOD1 = (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> dist1{2, MOD1 - 1};
    const ll base1 = dist1(mt);
    vector<ll> value1(N, 1);
    for (int i = 1; i < N; i++) {
        value1[i] = value1[i - 1] * base1;
        value1[i] %= MOD1;
    }
    ll x1 = 0;
    map<ll, int> hash;
    hash[0] = 0;
    for (int q = 0; q < Q; q++) {
        char c;
        cin >> c;
        if (c == '!') {
            int l, r;
            ll v;
            cin >> l >> r >> v;
            const ll add1 = ((r == N ? 0LL : value1[r] * ((MOD1 - v) % MOD1)) + value1[l] * ((MOD1 + v) % MOD1)) % MOD1;
            x1 = (x1 + add1) % MOD1;
            if (hash.find(x1) == hash.end()) {
                hash[x1] = q + 1;
            }
        } else {
            cout << hash[x1] << endl;
        }
    }

    return 0;
}
0