Please sign in first.
Submission #37361344
Source Code Expand
$stdout.sync = true
N = gets.to_i
W = lambda{|w|
(1<<(w+1).bit_length-1)-1
}
w,b = 0,1
M,*LR = {}
until W[N] < w = (b*=2)-1
M[w] = LR.size+1
1.upto(N-w+1).with_index(w){|l,r|
LR<<"#{l} #{r}"
}
end
puts LR.size,LR
gets.to_i.times{
l,r = gets.split.map(&:to_i)
w = W[r-l+1]
m,i,j = M[w],l-1,r-w
puts "#{m+i} #{m+j}"
}
Submission Info
| Submission Time | |
|---|---|
| Task | F - Union of Two Sets |
| User | ds14050 |
| Language | Ruby (2.7.1) |
| Score | 500 |
| Code Size | 352 Byte |
| Status | AC |
| Exec Time | 1060 ms |
| Memory | 17268 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 500 / 500 | ||||
| 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, example0.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 000.txt | AC | 886 ms | 14004 KiB |
| 001.txt | AC | 1030 ms | 16192 KiB |
| 002.txt | AC | 953 ms | 15312 KiB |
| 003.txt | AC | 1054 ms | 16132 KiB |
| 004.txt | AC | 1003 ms | 15964 KiB |
| 005.txt | AC | 1060 ms | 17268 KiB |
| 006.txt | AC | 964 ms | 15176 KiB |
| 007.txt | AC | 1015 ms | 15868 KiB |
| 008.txt | AC | 1046 ms | 17188 KiB |
| 009.txt | AC | 992 ms | 15176 KiB |
| 010.txt | AC | 1046 ms | 17164 KiB |
| 011.txt | AC | 515 ms | 16240 KiB |
| 012.txt | AC | 524 ms | 17060 KiB |
| 013.txt | AC | 592 ms | 17028 KiB |
| 014.txt | AC | 350 ms | 15932 KiB |
| 015.txt | AC | 609 ms | 17112 KiB |
| 016.txt | AC | 1021 ms | 16152 KiB |
| 017.txt | AC | 1046 ms | 16188 KiB |
| 018.txt | AC | 1005 ms | 15308 KiB |
| 019.txt | AC | 1040 ms | 16232 KiB |
| 020.txt | AC | 929 ms | 14660 KiB |
| 021.txt | AC | 1041 ms | 17016 KiB |
| example0.txt | AC | 56 ms | 14132 KiB |