Submission #44669970
Source Code Expand
class BIT
def initialize n
@n = n # accessing 0..n-1, 1..n internally.
@a = [0]*(@n+1)
end
def [] i
i += 1
s = 0
while 0<i
s += @a[i]
i &= i-1
end
return s
end
def inc i
i += 1
while i<=@n
@a[i] += 1
i += i&-i
end
end
end
P = 998244353
(N,),*XY = $<.map{|ln| ln.split.map(&:to_i) }
(X,IX),(Y,IY) = XY.transpose.map{|xs|
[xs.sort!,xs.each_with_index.to_h]
}
▀ = BIT.new N
F = Hash.new{|h,n| h[n] = 2.pow(n,P)-1 }
p XY.sort_by{_2}.sum{|x,y|
l = IX[x]
r = N-l-1
u = IY[y]
d = N-u-1
ul = ▀[l]
ur = u-ul
dl = l-ul
dr = d-dl
▀.inc l
next F[N]-F[l]-F[r]-F[u]-F[d]+F[ul]+F[ur]+F[dl]+F[dr]
}%P
Submission Info
| Submission Time | |
|---|---|
| Task | F - Enclosed Points |
| User | ds14050 |
| Language | Ruby (2.7.1) |
| Score | 600 |
| Code Size | 687 Byte |
| Status | AC |
| Exec Time | 1095 ms |
| Memory | 62636 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 600 / 600 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | s1.txt, s2.txt, s3.txt |
| All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, s1.txt, s2.txt, s3.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 01.txt | AC | 59 ms | 14336 KiB |
| 02.txt | AC | 57 ms | 14396 KiB |
| 03.txt | AC | 58 ms | 14292 KiB |
| 04.txt | AC | 57 ms | 14216 KiB |
| 05.txt | AC | 57 ms | 14276 KiB |
| 06.txt | AC | 57 ms | 14264 KiB |
| 07.txt | AC | 56 ms | 14412 KiB |
| 08.txt | AC | 55 ms | 14332 KiB |
| 09.txt | AC | 56 ms | 14284 KiB |
| 10.txt | AC | 57 ms | 14288 KiB |
| 11.txt | AC | 1095 ms | 58148 KiB |
| 12.txt | AC | 1022 ms | 59296 KiB |
| 13.txt | AC | 1049 ms | 62316 KiB |
| 14.txt | AC | 995 ms | 58052 KiB |
| 15.txt | AC | 1073 ms | 61660 KiB |
| 16.txt | AC | 1085 ms | 61900 KiB |
| 17.txt | AC | 1058 ms | 62636 KiB |
| 18.txt | AC | 1063 ms | 58584 KiB |
| 19.txt | AC | 917 ms | 58296 KiB |
| 20.txt | AC | 931 ms | 58548 KiB |
| 21.txt | AC | 970 ms | 62032 KiB |
| 22.txt | AC | 986 ms | 62004 KiB |
| 23.txt | AC | 58 ms | 14268 KiB |
| s1.txt | AC | 57 ms | 14288 KiB |
| s2.txt | AC | 55 ms | 14284 KiB |
| s3.txt | AC | 61 ms | 14396 KiB |