Submission #53993734


Source Code Expand

Copy
N,L,R,RZ = gets.split.map(&:to_i).then{|n,l,r| [n,l,r+1,1<<n] }
E = lambda{|s,&f|
Enumerator.new{|y|
0.upto(N){|i|
w = 1<<i
break if s!=s/w*w
l = s-w
r = s+w
y<<s-w if w<=s
y<<s+w if s+w<=RZ
}
}.each(&f)
}
IJK = lambda{|s,t|
l,r = [s,t].minmax
i = (r-l).bit_length-1
w = 1<<i
j = l/w
raise unless l==w*j && r==l+w
next i,j,t<=>s
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
N,L,R,RZ = gets.split.map(&:to_i).then{|n,l,r| [n,l,r+1,1<<n] }
E = lambda{|s,&f|
	Enumerator.new{|y|
		0.upto(N){|i|
			w = 1<<i
			break if s!=s/w*w
			l = s-w
			r = s+w
			y<<s-w if w<=s
			y<<s+w if s+w<=RZ
		}
	}.each(&f)
}
IJK = lambda{|s,t|
	l,r = [s,t].minmax
	i = (r-l).bit_length-1
	w = 1<<i
	j = l/w
	raise unless l==w*j && r==l+w
	next i,j,t<=>s
}
Mv = false ? lambda{
	ss = (1<<N).times.inject([0]){|ss,a| ss<<ss[-1]+Random.rand(0..99) }
	warn "! #{(ss[R]-ss[L])%100}"
	next lambda{|s,t|
		i,j,k = IJK[s,t]
		warn "? #{i} #{j}"
		a = (ss[[s,t].max]-ss[[s,t].min])%100
		warn a*k
		next a*k
	}
}.call : lambda{|s,t|
	i,j,k = IJK[s,t]
	puts "? #{i} #{j}"
	$stdout.flush
	a = gets.to_i
	exit if a<0
	warn a*k
	next a*k
}

D = [RZ]*(RZ+1)
D[L] = 0
*Q = L
while RZ<=D[R] && s = Q.shift
	d = D[s]+1
	E[s].each{|t|
		if d<D[t]
			D[t] = d
			Q<<t
		end
	}
end

a = 0
t = R
D[R].times{
	s = E[t].find{|s| D[s]+1==D[t] }
	a = (a+Mv[s,t])%100
	t = s
}

puts "! #{a}"
warn D[R]

Submission Info

Submission Time
Task E - Guess the Sum
User ds14050
Language Ruby (ruby 3.2.2)
Score 500
Code Size 1045 Byte
Status AC
Exec Time 402 ms
Memory 20552 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 1
AC × 38
Set Name Test Cases
Sample 00_sample_00.txt
All 00_sample_00.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 01_random_31.txt, 01_random_32.txt, 01_random_33.txt, 01_random_34.txt, 01_random_35.txt, 01_random_36.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 130 ms 17228 KB
01_random_00.txt AC 46 ms 17200 KB
01_random_01.txt AC 47 ms 17372 KB
01_random_02.txt AC 46 ms 17156 KB
01_random_03.txt AC 46 ms 17468 KB
01_random_04.txt AC 46 ms 17340 KB
01_random_05.txt AC 48 ms 17480 KB
01_random_06.txt AC 47 ms 17440 KB
01_random_07.txt AC 46 ms 17512 KB
01_random_08.txt AC 46 ms 17600 KB
01_random_09.txt AC 46 ms 17096 KB
01_random_10.txt AC 70 ms 18028 KB
01_random_11.txt AC 53 ms 17504 KB
01_random_12.txt AC 50 ms 17616 KB
01_random_13.txt AC 131 ms 18376 KB
01_random_14.txt AC 124 ms 18800 KB
01_random_15.txt AC 366 ms 20348 KB
01_random_16.txt AC 125 ms 19808 KB
01_random_17.txt AC 316 ms 20552 KB
01_random_18.txt AC 324 ms 20532 KB
01_random_19.txt AC 187 ms 20308 KB
01_random_20.txt AC 95 ms 19540 KB
01_random_21.txt AC 402 ms 20520 KB
01_random_22.txt AC 132 ms 20192 KB
01_random_23.txt AC 247 ms 20484 KB
01_random_24.txt AC 122 ms 19780 KB
01_random_25.txt AC 356 ms 20308 KB
01_random_26.txt AC 124 ms 20004 KB
01_random_27.txt AC 138 ms 20152 KB
01_random_28.txt AC 231 ms 20416 KB
01_random_29.txt AC 135 ms 19968 KB
01_random_30.txt AC 124 ms 19632 KB
01_random_31.txt AC 73 ms 19304 KB
01_random_32.txt AC 74 ms 19140 KB
01_random_33.txt AC 73 ms 19268 KB
01_random_34.txt AC 47 ms 17196 KB
01_random_35.txt AC 45 ms 17160 KB
01_random_36.txt AC 46 ms 17116 KB


2025-04-08 (Tue)
07:17:48 +00:00