結果

問題 No.469 区間加算と一致検索の問題
ユーザー kuuso1kuuso1
提出日時 2016-12-19 22:54:30
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,859 bytes
コンパイル時間 2,068 ms
コンパイル使用メモリ 115,444 KB
実行使用メモリ 53,620 KB
最終ジャッジ日時 2024-05-08 07:03:55
合計ジャッジ時間 9,729 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
19,200 KB
testcase_01 AC 31 ms
19,072 KB
testcase_02 AC 38 ms
19,840 KB
testcase_03 AC 37 ms
19,984 KB
testcase_04 AC 40 ms
20,324 KB
testcase_05 AC 39 ms
20,648 KB
testcase_06 AC 40 ms
20,880 KB
testcase_07 AC 41 ms
20,716 KB
testcase_08 AC 43 ms
20,776 KB
testcase_09 AC 36 ms
19,884 KB
testcase_10 AC 41 ms
20,728 KB
testcase_11 AC 35 ms
19,648 KB
testcase_12 AC 44 ms
21,376 KB
testcase_13 AC 40 ms
20,460 KB
testcase_14 AC 34 ms
19,412 KB
testcase_15 AC 35 ms
19,452 KB
testcase_16 AC 41 ms
20,652 KB
testcase_17 AC 42 ms
20,568 KB
testcase_18 AC 41 ms
20,792 KB
testcase_19 AC 33 ms
19,456 KB
testcase_20 AC 44 ms
20,960 KB
testcase_21 AC 35 ms
19,584 KB
testcase_22 AC 32 ms
19,200 KB
testcase_23 AC 102 ms
29,568 KB
testcase_24 AC 102 ms
29,184 KB
testcase_25 AC 101 ms
29,440 KB
testcase_26 AC 101 ms
29,312 KB
testcase_27 AC 101 ms
29,312 KB
testcase_28 AC 100 ms
29,312 KB
testcase_29 WA -
testcase_30 AC 103 ms
29,440 KB
testcase_31 AC 105 ms
29,440 KB
testcase_32 AC 102 ms
35,568 KB
testcase_33 AC 226 ms
44,672 KB
testcase_34 AC 220 ms
53,620 KB
testcase_35 WA -
testcase_36 AC 218 ms
44,416 KB
testcase_37 AC 223 ms
44,416 KB
testcase_38 WA -
testcase_39 AC 216 ms
41,856 KB
testcase_40 WA -
testcase_41 AC 218 ms
41,728 KB
testcase_42 AC 216 ms
41,856 KB
testcase_43 AC 210 ms
41,728 KB
testcase_44 AC 219 ms
41,728 KB
testcase_45 AC 213 ms
41,856 KB
testcase_46 WA -
testcase_47 AC 203 ms
47,844 KB
testcase_48 AC 30 ms
19,200 KB
testcase_49 AC 30 ms
18,944 KB
testcase_50 AC 208 ms
41,728 KB
testcase_51 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long mod = (long) 1e9+9;
		long[] ms = new long[N+1];
		var rnd = new Random();
		for(int i=0;i<N+1;i++){
			ms[i] = rnd.Next()%mod;
			if(ms[i] < 0) ms[i] += mod;
		}
		
		long[] res = new long[Q+1];
		long[] A = new long[N+1];
		long tot = 0;
		for(int i=0;i<N+1;i++) tot += A[i] * ms[i];
		res[0] = tot;
		Dictionary<long,int> his = new Dictionary<long,int>();
		his.Add(tot,0);
		List<int> L = new List<int>();
		for(int i=0;i<Q;i++){
			if(S[i][0] == '?'){
				res[i+1] = res[i];
				L.Add(his[res[i+1]]);
				continue;
			}
			
			var ss = S[i].Split();
			int a = int.Parse(ss[1]);
			int b = int.Parse(ss[2]);
			int k = int.Parse(ss[3]);
			
			tot += k * ms[a];
			tot -= k * ms[b];
			tot %= mod; if(tot<0) tot += mod;
			
			res[i+1] = tot;
			if(!his.ContainsKey(tot)){
				his.Add(tot,i+1);
			}
		}
		
		Console.WriteLine(String.Join("\n",L));
		
	}
	int N,Q;
	String[] S;
	public Sol(){
		var d = ria();
		N = d[0];
		Q = d[1];
		S = new String[Q];
		for(int i=0;i<Q;i++) S[i] = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}
0