結果

問題 No.469 区間加算と一致検索の問題
ユーザー hirokazu1020hirokazu1020
提出日時 2016-12-19 00:32:58
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 98 ms / 5,000 ms
コード長 1,266 bytes
コンパイル時間 1,303 ms
コンパイル使用メモリ 103,232 KB
実行使用メモリ 17,028 KB
最終ジャッジ日時 2023-08-23 13:19:24
合計ジャッジ時間 5,526 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 3 ms
4,396 KB
testcase_03 AC 5 ms
4,376 KB
testcase_04 AC 5 ms
4,376 KB
testcase_05 AC 6 ms
4,376 KB
testcase_06 AC 6 ms
4,380 KB
testcase_07 AC 6 ms
4,380 KB
testcase_08 AC 7 ms
4,380 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 7 ms
4,380 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 7 ms
4,376 KB
testcase_13 AC 5 ms
4,380 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 7 ms
4,376 KB
testcase_17 AC 6 ms
4,380 KB
testcase_18 AC 6 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 7 ms
4,380 KB
testcase_21 AC 3 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 34 ms
6,336 KB
testcase_24 AC 35 ms
6,312 KB
testcase_25 AC 33 ms
6,496 KB
testcase_26 AC 34 ms
6,340 KB
testcase_27 AC 34 ms
6,328 KB
testcase_28 AC 34 ms
6,352 KB
testcase_29 AC 34 ms
6,304 KB
testcase_30 AC 35 ms
6,312 KB
testcase_31 AC 34 ms
6,380 KB
testcase_32 AC 33 ms
6,268 KB
testcase_33 AC 92 ms
16,940 KB
testcase_34 AC 91 ms
16,880 KB
testcase_35 AC 91 ms
16,928 KB
testcase_36 AC 98 ms
17,028 KB
testcase_37 AC 90 ms
16,876 KB
testcase_38 AC 86 ms
15,444 KB
testcase_39 AC 89 ms
15,516 KB
testcase_40 AC 84 ms
15,404 KB
testcase_41 AC 86 ms
15,476 KB
testcase_42 AC 85 ms
15,480 KB
testcase_43 AC 84 ms
15,520 KB
testcase_44 AC 83 ms
15,428 KB
testcase_45 AC 84 ms
15,464 KB
testcase_46 AC 83 ms
15,732 KB
testcase_47 AC 85 ms
15,488 KB
testcase_48 AC 1 ms
4,376 KB
testcase_49 AC 2 ms
4,380 KB
testcase_50 AC 86 ms
15,404 KB
testcase_51 AC 83 ms
15,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#include<sstream>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())



unsigned int xor128() {
	static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	unsigned int t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
}


unsigned long long rhash[1000001];

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

	int n, q;
	scanf("%d%d", &n, &q);
	for (int i = 1; i <= n; i++) {
		rhash[i] = rhash[i - 1] + xor128();
	}
	unsigned long long cur = 0;
	map<unsigned long long, int> mp;
	mp[0] = 0;
	rep(i,q) {
		char c;
		scanf(" %c", &c);
		if (c == '?') {
			cout << mp[cur] << endl;
		}
		else {
			int l, r, k;
			scanf("%d%d%d", &l, &r, &k);
			cur += k * (rhash[r] - rhash[l]);
			auto it = mp.emplace(cur, i + 1);
		}
	}


	
	return 0;
}
0