Submission #50851673
Source Code Expand
class ST
def initialize a,e,&op
@l = (1<<(a.size-1).bit_length)
@a = [e]*@l+a
@a<<e
@op = op
((@l+a.size-1)/2).downto(1){|i|
@a[i] = @op[*@a[i+i,2]]
}
end
def [] l,r
return if r<l
l,r = l+@l,r+@l
al = @a[l]
ar = @a[r]
while l+1<r
al = @op[al,@a[l+1]] if l&1<1
ar = @op[@a[r-1],ar] if 0<r&1
l,r = l/2,r/2
end
return l==r ? al : @op[al,ar]
end
def []= i,v
i += @l
@a[i] = v
@a[i] = @op[*@a[i+i,2]] while 0<i/=2
return v
end
end
N,Q = gets.split.map(&:to_i)
A = 0,*gets.split.map(&:to_i)
XSYT = ST.new(A.map{|a| [a,1,0,0] },[0,0,0,0]){|(x,a,y,b),(v,c,w,d)|
t = Hash.new 0
t[x] += a
t[y] += b
t[v] += c
t[w] += d
x,y = *t.keys.sort.reverse,0
next x,t[x],y,t[y]
}
Q.times{
q,a,b = gets.split.map(&:to_i)
case q
when 1
XSYT[a] = [b,1,0,0]
when 2
puts XSYT[a,b][3]
end
}
Submission Info
| Submission Time | |
|---|---|
| Task | F - Second Largest Query |
| User | ds14050 |
| Language | Ruby (ruby 3.2.2) |
| Score | 0 |
| Code Size | 887 Byte |
| Status | TLE |
| Exec Time | 2215 ms |
| Memory | 102220 KiB |
Judge Result
| Set Name | Sample | All | ||||||
|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 525 | ||||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample00.txt, sample01.txt, sample02.txt |
| All | sample00.txt, sample01.txt, sample02.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt, testcase12.txt, testcase13.txt, testcase14.txt, testcase15.txt, testcase16.txt, testcase17.txt, testcase18.txt, testcase19.txt, testcase20.txt, testcase21.txt, testcase22.txt, testcase23.txt, testcase24.txt, testcase25.txt, testcase26.txt, testcase27.txt, testcase28.txt, testcase29.txt, testcase30.txt, testcase31.txt, testcase32.txt, testcase33.txt, testcase34.txt, testcase35.txt, testcase36.txt, testcase37.txt, testcase38.txt, testcase39.txt, testcase40.txt, testcase41.txt, testcase42.txt, testcase43.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| sample00.txt | AC | 101 ms | 16820 KiB |
| sample01.txt | AC | 45 ms | 17112 KiB |
| sample02.txt | AC | 49 ms | 17424 KiB |
| testcase00.txt | TLE | 2213 ms | 90332 KiB |
| testcase01.txt | TLE | 2212 ms | 90464 KiB |
| testcase02.txt | TLE | 2212 ms | 86584 KiB |
| testcase03.txt | TLE | 2213 ms | 90492 KiB |
| testcase04.txt | TLE | 2213 ms | 89368 KiB |
| testcase05.txt | TLE | 2213 ms | 90416 KiB |
| testcase06.txt | TLE | 2212 ms | 87292 KiB |
| testcase07.txt | TLE | 2213 ms | 90504 KiB |
| testcase08.txt | TLE | 2215 ms | 88460 KiB |
| testcase09.txt | TLE | 2212 ms | 90304 KiB |
| testcase10.txt | TLE | 2213 ms | 90168 KiB |
| testcase11.txt | TLE | 2213 ms | 90468 KiB |
| testcase12.txt | TLE | 2212 ms | 87108 KiB |
| testcase13.txt | TLE | 2213 ms | 90576 KiB |
| testcase14.txt | TLE | 2213 ms | 88524 KiB |
| testcase15.txt | TLE | 2212 ms | 90520 KiB |
| testcase16.txt | TLE | 2212 ms | 89516 KiB |
| testcase17.txt | TLE | 2213 ms | 93504 KiB |
| testcase18.txt | TLE | 2213 ms | 93408 KiB |
| testcase19.txt | TLE | 2213 ms | 95832 KiB |
| testcase20.txt | TLE | 2213 ms | 94808 KiB |
| testcase21.txt | TLE | 2213 ms | 97736 KiB |
| testcase22.txt | TLE | 2213 ms | 95660 KiB |
| testcase23.txt | TLE | 2213 ms | 98748 KiB |
| testcase24.txt | TLE | 2213 ms | 97144 KiB |
| testcase25.txt | TLE | 2213 ms | 100020 KiB |
| testcase26.txt | TLE | 2213 ms | 97580 KiB |
| testcase27.txt | TLE | 2213 ms | 101744 KiB |
| testcase28.txt | TLE | 2213 ms | 96520 KiB |
| testcase29.txt | TLE | 2213 ms | 102220 KiB |
| testcase30.txt | TLE | 2215 ms | 88920 KiB |
| testcase31.txt | TLE | 2211 ms | 90448 KiB |
| testcase32.txt | TLE | 2213 ms | 89348 KiB |
| testcase33.txt | TLE | 2213 ms | 90600 KiB |
| testcase34.txt | TLE | 2213 ms | 90076 KiB |
| testcase35.txt | TLE | 2213 ms | 90448 KiB |
| testcase36.txt | TLE | 2213 ms | 88276 KiB |
| testcase37.txt | TLE | 2213 ms | 90540 KiB |
| testcase38.txt | TLE | 2213 ms | 89796 KiB |
| testcase39.txt | TLE | 2212 ms | 90360 KiB |
| testcase40.txt | TLE | 2212 ms | 87968 KiB |
| testcase41.txt | TLE | 2212 ms | 90372 KiB |
| testcase42.txt | TLE | 2213 ms | 89752 KiB |
| testcase43.txt | TLE | 2213 ms | 90564 KiB |