Submission #38074190


Source Code Expand

N = gets.to_i
R = []
S = gets.chomp.bytes
S.each_cons(2).with_index{|(c1,c2),i|
	R<<i if c1>c2
}
A = []
gets.to_i.times{
	q,a1,a2 = gets.split
	case q.to_i
	when 1
		x,c = a1.to_i-1,a2.ord
		i = R.bsearch_index{|i| x<=i }||R.size
		r00 = 0<x && S[x-1]>S[x]
		r01 = x+1<N && S[x]>S[x+1]
		r10 = 0<x && S[x-1]>c
		r11 = x+1<N && c>S[x+1]
		if r00!=r10
			if r00
				R.delete_at i-1
				i -= 1
			else
				R.insert i,x-1
				i += 1
			end
		end
		if r01!=r11
			if r01
				R.delete_at i
			else
				R.insert i,x
			end
		end
		S[x] = c
	when 2
		l,r = a1.to_i-1,a2.to_i-1
		i = R.bsearch{|i| l<=i }
		A<<(i&&i<r ? 'No':'Yes')
	end
}
puts A

Submission Info

Submission Time
Task F - Substring of Sorted String
User ds14050
Language Ruby (2.7.1)
Score 0
Code Size 678 Byte
Status WA
Exec Time 367 ms
Memory 21376 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 1
AC × 15
WA × 9
Set Name Test Cases
Sample sample_01.txt
All hand.txt, min.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, sample_01.txt
Case Name Status Exec Time Memory
hand.txt WA 60 ms 14056 KiB
min.txt AC 58 ms 14172 KiB
random_01.txt AC 193 ms 20716 KiB
random_02.txt AC 198 ms 20740 KiB
random_03.txt AC 183 ms 18608 KiB
random_04.txt AC 187 ms 18756 KiB
random_05.txt AC 167 ms 15780 KiB
random_06.txt AC 168 ms 15600 KiB
random_07.txt WA 201 ms 21044 KiB
random_08.txt WA 201 ms 20728 KiB
random_09.txt WA 196 ms 18720 KiB
random_10.txt WA 195 ms 18736 KiB
random_11.txt WA 176 ms 15608 KiB
random_12.txt WA 175 ms 15664 KiB
random_13.txt WA 286 ms 21216 KiB
random_14.txt AC 288 ms 21080 KiB
random_15.txt WA 367 ms 18972 KiB
random_16.txt AC 196 ms 21376 KiB
random_17.txt AC 198 ms 21352 KiB
random_18.txt AC 198 ms 20936 KiB
random_19.txt AC 196 ms 20988 KiB
random_20.txt AC 197 ms 20888 KiB
random_21.txt AC 196 ms 20932 KiB
sample_01.txt AC 61 ms 14072 KiB