結果

問題 No.469 区間加算と一致検索の問題
ユーザー tubo28
提出日時 2016-12-20 15:48:09
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 55 ms / 5,000 ms
コード長 727 bytes
コンパイル時間 1,711 ms
コンパイル使用メモリ 173,796 KB
実行使用メモリ 15,912 KB
最終ジャッジ日時 2024-12-21 17:01:06
合計ジャッジ時間 4,449 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 49
権限があれば一括ダウンロードができます

ソースコード

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 = unsigned long long;
LL s[1000010];
unordered_map<LL, int> first;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	int n, q;
	cin >> n >> q;
	s[0] = 1;
	const int r = time(0) | 1;
	for(int i = 0; i < n; ++i) s[i+1] = s[i] * r;
	LL cur = 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; ll k;
			cin >> l >> r >> k;
			cur += (LL)(s[r] - s[l]) * k;
		}
		if(!first.count(cur)) first[cur] = i + 1;
	}
}
0