結果

問題 No.469 区間加算と一致検索の問題
ユーザー 37zigen37zigen
提出日時 2016-12-20 12:27:31
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 988 bytes
コンパイル時間 3,581 ms
コンパイル使用メモリ 78,476 KB
実行使用メモリ 100,244 KB
最終ジャッジ日時 2024-05-08 08:34:58
合計ジャッジ時間 55,623 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
54,256 KB
testcase_01 AC 130 ms
53,932 KB
testcase_02 AC 144 ms
56,060 KB
testcase_03 AC 320 ms
59,224 KB
testcase_04 AC 345 ms
59,336 KB
testcase_05 AC 355 ms
59,280 KB
testcase_06 AC 372 ms
59,360 KB
testcase_07 AC 400 ms
59,480 KB
testcase_08 AC 429 ms
59,680 KB
testcase_09 AC 296 ms
59,356 KB
testcase_10 WA -
testcase_11 AC 268 ms
58,508 KB
testcase_12 AC 411 ms
59,424 KB
testcase_13 AC 345 ms
59,732 KB
testcase_14 AC 238 ms
57,960 KB
testcase_15 AC 278 ms
58,468 KB
testcase_16 AC 389 ms
59,660 KB
testcase_17 AC 386 ms
59,520 KB
testcase_18 AC 378 ms
59,384 KB
testcase_19 AC 235 ms
57,952 KB
testcase_20 AC 434 ms
59,572 KB
testcase_21 AC 258 ms
58,304 KB
testcase_22 AC 185 ms
54,944 KB
testcase_23 AC 1,161 ms
74,044 KB
testcase_24 AC 878 ms
65,644 KB
testcase_25 AC 1,130 ms
74,976 KB
testcase_26 AC 1,171 ms
74,364 KB
testcase_27 AC 1,132 ms
73,440 KB
testcase_28 AC 1,226 ms
73,936 KB
testcase_29 AC 1,220 ms
74,472 KB
testcase_30 AC 869 ms
65,700 KB
testcase_31 AC 987 ms
67,532 KB
testcase_32 AC 907 ms
65,004 KB
testcase_33 AC 4,703 ms
100,244 KB
testcase_34 AC 2,751 ms
98,768 KB
testcase_35 AC 3,881 ms
100,092 KB
testcase_36 AC 2,287 ms
98,244 KB
testcase_37 AC 1,335 ms
97,576 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 TLE -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;

import java.util.HashMap;
import java.util.Scanner;

public class Q469 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		long p1 = 1_000_000 + 7;
		long m1 = 1_000_000 + 9;
		long[] pow = new long[n];
		pow[0] = 1;
		for (int i = 1; i < n; ++i) {
			pow[i] = pow[i - 1] * p1 % m1;
		}
		long[] accum = new long[n];
		accum[0] = pow[0];
		for (int i = 1; i < n; ++i) {
			accum[i] = accum[i - 1] + pow[i];
		}

		HashMap<Long, Integer> map = new HashMap<>();
		map.put(0L, 0);
		long h1 = 0;
		for (int query = 0; query < q; ++query) {
			String s = sc.next();
			if (s.equals("!")) {
				int l = sc.nextInt();
				int r = sc.nextInt();
				int k = sc.nextInt();
				h1 += (accum[r - 1] - (l > 0 ? accum[l - 1] : 0)) * k;
				while (h1 < 0)
					h1 += m1;
				if (!map.containsKey(h1)) {
					map.put(h1, query + 1);
				}
			} else {
				System.out.println(map.get(h1));
			}
		}
	}
}
0