結果

問題 No.469 区間加算と一致検索の問題
ユーザー FF256grhyFF256grhy
提出日時 2016-12-23 18:15:19
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 163 ms / 5,000 ms
コード長 2,190 bytes
コンパイル時間 1,256 ms
コンパイル使用メモリ 153,396 KB
実行使用メモリ 18,144 KB
最終ジャッジ日時 2023-08-23 13:37:10
合計ジャッジ時間 6,858 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,432 KB
testcase_01 AC 2 ms
5,416 KB
testcase_02 AC 3 ms
6,152 KB
testcase_03 AC 6 ms
5,676 KB
testcase_04 AC 7 ms
5,804 KB
testcase_05 AC 8 ms
5,904 KB
testcase_06 AC 9 ms
5,992 KB
testcase_07 AC 10 ms
6,204 KB
testcase_08 AC 11 ms
5,992 KB
testcase_09 AC 5 ms
5,620 KB
testcase_10 AC 9 ms
5,568 KB
testcase_11 AC 5 ms
5,636 KB
testcase_12 AC 11 ms
6,108 KB
testcase_13 AC 8 ms
5,728 KB
testcase_14 AC 4 ms
5,664 KB
testcase_15 AC 4 ms
5,684 KB
testcase_16 AC 10 ms
5,996 KB
testcase_17 AC 9 ms
6,176 KB
testcase_18 AC 10 ms
5,892 KB
testcase_19 AC 3 ms
5,580 KB
testcase_20 AC 11 ms
6,000 KB
testcase_21 AC 4 ms
5,528 KB
testcase_22 AC 2 ms
5,496 KB
testcase_23 AC 60 ms
8,852 KB
testcase_24 AC 60 ms
8,688 KB
testcase_25 AC 59 ms
8,684 KB
testcase_26 AC 61 ms
8,860 KB
testcase_27 AC 60 ms
8,800 KB
testcase_28 AC 60 ms
8,808 KB
testcase_29 AC 61 ms
8,756 KB
testcase_30 AC 61 ms
8,848 KB
testcase_31 AC 61 ms
8,764 KB
testcase_32 AC 60 ms
8,760 KB
testcase_33 AC 163 ms
18,112 KB
testcase_34 AC 159 ms
18,020 KB
testcase_35 AC 160 ms
18,044 KB
testcase_36 AC 154 ms
18,036 KB
testcase_37 AC 159 ms
18,144 KB
testcase_38 AC 146 ms
16,560 KB
testcase_39 AC 145 ms
16,668 KB
testcase_40 AC 147 ms
16,580 KB
testcase_41 AC 147 ms
16,652 KB
testcase_42 AC 149 ms
16,692 KB
testcase_43 AC 151 ms
16,636 KB
testcase_44 AC 147 ms
16,768 KB
testcase_45 AC 148 ms
16,632 KB
testcase_46 AC 147 ms
16,632 KB
testcase_47 AC 146 ms
16,616 KB
testcase_48 AC 2 ms
5,432 KB
testcase_49 AC 2 ms
5,380 KB
testcase_50 AC 149 ms
16,828 KB
testcase_51 AC 146 ms
16,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define inc( i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec( i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(i, v) for(auto i =  v.begin(); i !=  v.end(); ++i)
#define RFOR(i, v) for(auto i = v.rbegin(); i != v.rend(); ++i)

template<typename T> bool setmin(T & a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T & a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T> ostream & operator<<(ostream & os, const vector<T> & v) {
	os << "[";
	FOR(it, v) {
		if(it != v.begin()) { os << ", "; }
		os << *it;
	}
	os << "]";
	return os;
}
template<typename F, typename S> ostream & operator<<(ostream & os, const pair<F, S> & p) {
	os << "<" << p.FI << ", " << p.SE << ">";
	return os;
}

// ---- ----

int n, q;
char c[100000];
int l[100000], r[100000], k[100000];
map<LL, int> mm;
LL tekitou[1000000];

int main() {
	cin >> n >> q;
	
	inc(i, q) {
		cin >> c[i];
		if(c[i] == '!') { cin >> l[i] >> r[i] >> k[i]; }
	}
	
	inc(i, n) {
		if(i == 0) { tekitou[i] = 777; }
		else { tekitou[i] = tekitou[i - 1] * 314159; }
	}
	
	LL ha = 1;
	inc(i, q) {
		mm.insert(MP(ha, i));
		if(c[i] == '!') {
			ha += tekitou[ l[i] ] * k[i];
			ha -= tekitou[ r[i] ] * k[i];
		} else {
			cout << mm[ha] << endl;
		}
	}
	
	return 0;
}
0