結果

問題 No.469 区間加算と一致検索の問題
ユーザー hirokazu1020hirokazu1020
提出日時 2016-12-19 00:31:29
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,273 bytes
コンパイル時間 4,083 ms
コンパイル使用メモリ 104,360 KB
実行使用メモリ 12,128 KB
最終ジャッジ日時 2024-05-08 06:48:18
合計ジャッジ時間 5,479 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 4 ms
5,376 KB
testcase_04 AC 5 ms
5,376 KB
testcase_05 AC 5 ms
5,376 KB
testcase_06 AC 6 ms
5,376 KB
testcase_07 AC 7 ms
5,376 KB
testcase_08 AC 7 ms
5,376 KB
testcase_09 AC 4 ms
5,376 KB
testcase_10 AC 6 ms
5,376 KB
testcase_11 AC 3 ms
5,376 KB
testcase_12 AC 8 ms
5,376 KB
testcase_13 AC 5 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 3 ms
5,376 KB
testcase_16 AC 7 ms
5,376 KB
testcase_17 AC 6 ms
5,376 KB
testcase_18 AC 6 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 7 ms
5,376 KB
testcase_21 AC 3 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 35 ms
5,728 KB
testcase_24 AC 34 ms
5,728 KB
testcase_25 AC 36 ms
5,852 KB
testcase_26 AC 34 ms
5,724 KB
testcase_27 AC 34 ms
5,760 KB
testcase_28 AC 34 ms
5,596 KB
testcase_29 WA -
testcase_30 AC 35 ms
5,724 KB
testcase_31 AC 34 ms
5,724 KB
testcase_32 AC 34 ms
5,596 KB
testcase_33 AC 95 ms
12,004 KB
testcase_34 AC 100 ms
12,000 KB
testcase_35 WA -
testcase_36 AC 95 ms
11,860 KB
testcase_37 AC 99 ms
11,996 KB
testcase_38 AC 88 ms
10,076 KB
testcase_39 AC 83 ms
10,076 KB
testcase_40 AC 89 ms
9,948 KB
testcase_41 AC 90 ms
9,952 KB
testcase_42 AC 89 ms
10,104 KB
testcase_43 AC 85 ms
10,080 KB
testcase_44 AC 85 ms
10,084 KB
testcase_45 AC 82 ms
9,996 KB
testcase_46 AC 81 ms
9,952 KB
testcase_47 AC 82 ms
9,956 KB
testcase_48 AC 2 ms
5,376 KB
testcase_49 AC 2 ms
5,376 KB
testcase_50 AC 81 ms
10,076 KB
testcase_51 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:45:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   45 |         scanf("%d%d", &n, &q);
      |         ~~~~~^~~~~~~~~~~~~~~~
main.cpp:54:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   54 |                 scanf(" %c", &c);
      |                 ~~~~~^~~~~~~~~~~
main.cpp:60:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   60 |                         scanf("%d%d%d", &l, &r, &k);
      |                         ~~~~~^~~~~~~~~~~~~~~~~~~~~~

ソースコード

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<unordered_map>
#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 int 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 int cur = 0;
	unordered_map<int, 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