Submission #16923745
Source Code Expand
Copy
class BITdef initialize n@a = [0]*nenddef [] ii += 1s = 0while 0 < is += @a[i-1]i -= i&-iendreturn senddef []= i,nd = n-self[i]return unless 0 < d # allow increasing update onlyi += 1until @a.size < i@a[i-1] += d
class BIT def initialize n @a = [0]*n end def [] i i += 1 s = 0 while 0 < i s += @a[i-1] i -= i&-i end return s end def []= i,n d = n-self[i] return unless 0 < d # allow increasing update only i += 1 until @a.size < i @a[i-1] += d i += i&-i end end end N,Q = gets.split.map(&:to_i) bk = (N-2)**2 bb = BIT.new(N-1),BIT.new(N-1) Q.times{ b,x = gets.split.map(&:to_i).then{|b,x| [b-1,N-x] } y = bb[1-b][x] bk -= N-2-y bb[b][y] = x } p bk
Submission Info
Submission Time | |
---|---|
Task | F - Simplified Reversi |
User | ds14050 |
Language | Ruby (2.7.1) |
Score | 600 |
Code Size | 518 Byte |
Status | AC |
Exec Time | 513 ms |
Memory | 17472 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 600 / 600 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt, sample_03.txt |
All | hand_01.txt, hand_02.txt, hand_03.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, sample_01.txt, sample_02.txt, sample_03.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
hand_01.txt | AC | 60 ms | 14252 KB |
hand_02.txt | AC | 63 ms | 14160 KB |
hand_03.txt | AC | 61 ms | 14192 KB |
random_01.txt | AC | 420 ms | 17328 KB |
random_02.txt | AC | 110 ms | 17012 KB |
random_03.txt | AC | 425 ms | 17472 KB |
random_04.txt | AC | 237 ms | 16012 KB |
random_05.txt | AC | 399 ms | 17308 KB |
random_06.txt | AC | 330 ms | 15736 KB |
random_07.txt | AC | 414 ms | 17388 KB |
random_08.txt | AC | 98 ms | 15996 KB |
random_09.txt | AC | 400 ms | 17156 KB |
random_10.txt | AC | 55 ms | 14480 KB |
random_11.txt | AC | 306 ms | 17300 KB |
random_12.txt | AC | 395 ms | 16268 KB |
random_13.txt | AC | 513 ms | 15812 KB |
random_14.txt | AC | 493 ms | 15776 KB |
random_15.txt | AC | 486 ms | 15760 KB |
sample_01.txt | AC | 57 ms | 14216 KB |
sample_02.txt | AC | 63 ms | 17148 KB |
sample_03.txt | AC | 59 ms | 16820 KB |