結果

問題 No.469 区間加算と一致検索の問題
ユーザー tubo28tubo28
提出日時 2016-12-20 15:40:29
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 214 ms / 5,000 ms
コード長 941 bytes
コンパイル時間 1,634 ms
コンパイル使用メモリ 173,588 KB
実行使用メモリ 43,220 KB
最終ジャッジ日時 2023-08-23 13:31:16
合計ジャッジ時間 8,196 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,376 KB
testcase_01 AC 2 ms
5,480 KB
testcase_02 AC 11 ms
9,144 KB
testcase_03 AC 5 ms
5,844 KB
testcase_04 AC 5 ms
5,892 KB
testcase_05 AC 6 ms
5,976 KB
testcase_06 AC 7 ms
6,040 KB
testcase_07 AC 7 ms
6,076 KB
testcase_08 AC 8 ms
6,244 KB
testcase_09 AC 4 ms
5,756 KB
testcase_10 AC 5 ms
5,612 KB
testcase_11 AC 4 ms
5,604 KB
testcase_12 AC 8 ms
6,200 KB
testcase_13 AC 6 ms
5,900 KB
testcase_14 AC 3 ms
5,552 KB
testcase_15 AC 4 ms
5,676 KB
testcase_16 AC 8 ms
6,316 KB
testcase_17 AC 7 ms
6,064 KB
testcase_18 AC 7 ms
6,104 KB
testcase_19 AC 3 ms
5,516 KB
testcase_20 AC 8 ms
6,208 KB
testcase_21 AC 3 ms
5,572 KB
testcase_22 AC 3 ms
5,420 KB
testcase_23 AC 47 ms
9,792 KB
testcase_24 AC 50 ms
9,968 KB
testcase_25 AC 47 ms
9,852 KB
testcase_26 AC 49 ms
9,784 KB
testcase_27 AC 49 ms
9,800 KB
testcase_28 AC 49 ms
9,848 KB
testcase_29 AC 46 ms
9,756 KB
testcase_30 AC 49 ms
9,904 KB
testcase_31 AC 49 ms
9,952 KB
testcase_32 AC 51 ms
9,848 KB
testcase_33 AC 213 ms
43,220 KB
testcase_34 AC 214 ms
43,104 KB
testcase_35 AC 207 ms
43,024 KB
testcase_36 AC 207 ms
43,080 KB
testcase_37 AC 210 ms
43,132 KB
testcase_38 AC 188 ms
40,964 KB
testcase_39 AC 190 ms
41,124 KB
testcase_40 AC 186 ms
41,172 KB
testcase_41 AC 191 ms
40,952 KB
testcase_42 AC 189 ms
40,936 KB
testcase_43 AC 192 ms
40,892 KB
testcase_44 AC 190 ms
40,904 KB
testcase_45 AC 187 ms
40,872 KB
testcase_46 AC 193 ms
40,980 KB
testcase_47 AC 188 ms
40,880 KB
testcase_48 AC 2 ms
5,404 KB
testcase_49 AC 2 ms
5,468 KB
testcase_50 AC 197 ms
41,056 KB
testcase_51 AC 188 ms
40,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << (x) << endl

using LL = __int128;

LL MS = 1000000000000000003;
LL MT = 1000000000000000009;
LL s[1000010], t[1000010];
map<pair<LL,LL>, int> first;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	int n, q;
	cin >> n >> q;
	s[0] = t[0] = 1;
	for(int i = 0; i < n; ++i) s[i+1] = s[i] * 114 % MS;
	for(int i = 0; i < n; ++i) t[i+1] = t[i] * 514 % MT;
	pair<LL,LL> cur(0, 0);
	first[cur] = 0;
	for(int i = 0; i < q; ++i){
		char c;
		cin >> c;
		if(c == '?'){
			cout << first[cur] << '\n';
		} else {
			int l, r, k;
			cin >> l >> r >> k;
			cur.first  += (s[r] - s[l] + MS) * (k + MS);
			cur.first  %= MS;
			cur.second += (t[r] - t[l] + MT) * (k + MT);
			cur.second %= MT;
			if(!first.count(cur)) first[cur] = i + 1;
		}
	}
}
0