Submission #24413254
Source Code Expand
class ST
def initialize a
@l = (1<<(a.size-1).bit_length)-1
@h = [a[-1]]*@l+a
((@l+a.size-2)/2).downto(0){|i|
@h[i] = @h[i+i+1,2].min
}
@h<<a[-1]
end
def [] l,r
lm,rm = @h[l+=@l],@h[r+=@l]
l,r,lm,rm = l/2,r/2-1,[@h[l],lm].min,[@h[r],rm].min until r<l
return [lm,rm].min
end
def is l,r
is,i0,w,m = [0],0,@l+1,self[l,r]
until w<2 || is.empty?
i0 += (@l+1)/w
w /= 2
is = is.inject([]){|a,i|
a<<i if @h[i0+i+=i]<=m
a<<i if @h[i0+i+=1]<=m
next a
}
is.shift while is[0] && is[0]*w+w<=l
is.pop while is[-1] && r<is[-1]*w
end
return is
end
def []= i,v
i += @l
@h[i] = v
@h[i] = @h[i+i+1,2].min while 0<=i=(i-1)/2
return v
end
end
N,Q = gets.split.map(&:to_i)
A = 10**9,*gets.split.map(&:to_i)
M = ST.new A
Q.times{
t,x,y = gets.split.map(&:to_i)
if t<2
M[x] = A[x] = y if A[x]!=y
else
is = M.is x,y
print is.size,' ',is*' ',"\n"
end
}
Submission Info
| Submission Time | |
|---|---|
| Task | L - Multiple Min Query |
| User | ds14050 |
| Language | Ruby (2.7.1) |
| Score | 6 |
| Code Size | 966 Byte |
| Status | AC |
| Exec Time | 1861 ms |
| Memory | 57384 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 6 / 6 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | example0.txt |
| All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, 033.txt, 034.txt, 035.txt, 036.txt, 037.txt, 038.txt, 039.txt, 040.txt, 041.txt, example0.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 000.txt | AC | 227 ms | 14284 KiB |
| 001.txt | AC | 220 ms | 14176 KiB |
| 002.txt | AC | 893 ms | 14244 KiB |
| 003.txt | AC | 903 ms | 14120 KiB |
| 004.txt | AC | 867 ms | 14224 KiB |
| 005.txt | AC | 867 ms | 14164 KiB |
| 006.txt | AC | 859 ms | 14188 KiB |
| 007.txt | AC | 858 ms | 14216 KiB |
| 008.txt | AC | 163 ms | 15944 KiB |
| 009.txt | AC | 161 ms | 16052 KiB |
| 010.txt | AC | 346 ms | 16248 KiB |
| 011.txt | AC | 339 ms | 16020 KiB |
| 012.txt | AC | 602 ms | 15656 KiB |
| 013.txt | AC | 598 ms | 15572 KiB |
| 014.txt | AC | 1175 ms | 15676 KiB |
| 015.txt | AC | 1167 ms | 15508 KiB |
| 016.txt | AC | 221 ms | 40800 KiB |
| 017.txt | AC | 237 ms | 41388 KiB |
| 018.txt | AC | 372 ms | 53020 KiB |
| 019.txt | AC | 374 ms | 53012 KiB |
| 020.txt | AC | 430 ms | 57044 KiB |
| 021.txt | AC | 423 ms | 57384 KiB |
| 022.txt | AC | 1549 ms | 37132 KiB |
| 023.txt | AC | 1544 ms | 37084 KiB |
| 024.txt | AC | 1343 ms | 15496 KiB |
| 025.txt | AC | 1336 ms | 15636 KiB |
| 026.txt | AC | 1343 ms | 15408 KiB |
| 027.txt | AC | 1509 ms | 36664 KiB |
| 028.txt | AC | 1487 ms | 36588 KiB |
| 029.txt | AC | 1702 ms | 36612 KiB |
| 030.txt | AC | 1402 ms | 15320 KiB |
| 031.txt | AC | 1391 ms | 15572 KiB |
| 032.txt | AC | 1393 ms | 15552 KiB |
| 033.txt | AC | 1861 ms | 37424 KiB |
| 034.txt | AC | 1854 ms | 37572 KiB |
| 035.txt | AC | 1697 ms | 36480 KiB |
| 036.txt | AC | 720 ms | 22672 KiB |
| 037.txt | AC | 723 ms | 22644 KiB |
| 038.txt | AC | 723 ms | 21932 KiB |
| 039.txt | AC | 891 ms | 41628 KiB |
| 040.txt | AC | 900 ms | 41520 KiB |
| 041.txt | AC | 899 ms | 41548 KiB |
| example0.txt | AC | 57 ms | 14168 KiB |