結果

問題 No.469 区間加算と一致検索の問題
ユーザー hirokazu1020hirokazu1020
提出日時 2016-12-19 00:19:35
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 107 ms / 5,000 ms
コード長 1,051 bytes
コンパイル時間 801 ms
コンパイル使用メモリ 100,628 KB
実行使用メモリ 16,824 KB
最終ジャッジ日時 2023-08-23 13:17:48
合計ジャッジ時間 5,389 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 4 ms
4,376 KB
testcase_04 AC 5 ms
4,376 KB
testcase_05 AC 5 ms
4,380 KB
testcase_06 AC 6 ms
4,376 KB
testcase_07 AC 6 ms
4,376 KB
testcase_08 AC 7 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 7 ms
4,376 KB
testcase_13 AC 5 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 7 ms
4,380 KB
testcase_17 AC 6 ms
4,376 KB
testcase_18 AC 6 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 7 ms
4,380 KB
testcase_21 AC 3 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 37 ms
6,284 KB
testcase_24 AC 37 ms
6,448 KB
testcase_25 AC 36 ms
6,232 KB
testcase_26 AC 36 ms
6,440 KB
testcase_27 AC 38 ms
6,320 KB
testcase_28 AC 37 ms
6,296 KB
testcase_29 AC 36 ms
6,152 KB
testcase_30 AC 36 ms
6,316 KB
testcase_31 AC 36 ms
6,148 KB
testcase_32 AC 36 ms
6,308 KB
testcase_33 AC 102 ms
16,776 KB
testcase_34 AC 104 ms
16,824 KB
testcase_35 AC 107 ms
16,764 KB
testcase_36 AC 104 ms
16,704 KB
testcase_37 AC 105 ms
16,688 KB
testcase_38 AC 94 ms
15,424 KB
testcase_39 AC 91 ms
15,440 KB
testcase_40 AC 91 ms
15,368 KB
testcase_41 AC 90 ms
15,436 KB
testcase_42 AC 91 ms
15,580 KB
testcase_43 AC 88 ms
15,412 KB
testcase_44 AC 94 ms
15,364 KB
testcase_45 AC 93 ms
15,344 KB
testcase_46 AC 95 ms
15,356 KB
testcase_47 AC 91 ms
15,348 KB
testcase_48 AC 2 ms
4,380 KB
testcase_49 AC 2 ms
4,380 KB
testcase_50 AC 90 ms
15,404 KB
testcase_51 AC 89 ms
15,356 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 long long rhash[1000001];

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

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


	
	return 0;
}
0