Contest Duration: - (local time) (100 minutes) Back to Home

Submission #6698456

Source Code Expand

Copy
```import sys
from operator import itemgetter

stdin = sys.stdin

ni = lambda: int(ns())
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()

co = []
for i in range(n):
co.append(na())

co.sort(key=itemgetter(1))
for i in range(n):
co[i][1] = i

# print(co)
ft = [0] * (n + 5)

co.sort(key=itemgetter(0), reverse=True)

ups = [0] * n
downs = [0] * n

if v == 0 or i < 0: return
i += 1
while i < len(ft):
ft[i] += v
i += i&-i

def sumfenwick(ft, i):
s = 0
i += 1
while i > 0:
s += ft[i]
i -= i&-i
return s

for i in range(n):
c = co[i]
downs[n-1-i] = sumfenwick(ft, c[1])
ups[n-1-i] = i - downs[n-1-i]

ft = [0] * (n+5)
co = co[::-1]

mod = 998244353
ps = [0] * (n+5)
ps[0] = 1
for i in range(1, n+4):
ps[i] = ps[i-1] * 2 % mod

ans = 0
for i in range(n):
c = co[i]
d = sumfenwick(ft, c[1])
u = i - d

# print(d, u, ups[i], downs[i])
ans += (ps[d]-1) * (ps[ups[i]]-1) * ps[u+downs[i]]
ans += (ps[u]-1) * (ps[downs[i]]-1) * ps[d+ups[i]]
ans -= (ps[d]-1) * (ps[ups[i]]-1) * (ps[downs[i]]-1) * (ps[u]-1)
ans += ps[n-1]

ans %= mod
if ans < 0:
ans += mod
print(ans)

```

Submission Info

Submission Time 2019-08-04 21:36:24+0900 F - Enclosed Points uwi PyPy3 (2.4.0) 600 1413 Byte AC 1350 ms 102620 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
 AC × 3
 AC × 26
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 163 ms 38384 KB
02.txt AC 160 ms 38256 KB
03.txt AC 160 ms 38256 KB
04.txt AC 162 ms 38384 KB
05.txt AC 161 ms 38256 KB
06.txt AC 160 ms 38256 KB
07.txt AC 161 ms 38256 KB
08.txt AC 161 ms 38256 KB
09.txt AC 161 ms 38256 KB
10.txt AC 161 ms 38256 KB
11.txt AC 1311 ms 101852 KB
12.txt AC 1288 ms 100700 KB
13.txt AC 1330 ms 102364 KB
14.txt AC 1293 ms 100060 KB
15.txt AC 1339 ms 102620 KB
16.txt AC 1350 ms 102388 KB
17.txt AC 1304 ms 102620 KB
18.txt AC 1307 ms 102364 KB
19.txt AC 1052 ms 101468 KB
20.txt AC 1041 ms 100968 KB
21.txt AC 1206 ms 102236 KB
22.txt AC 1128 ms 102364 KB
23.txt AC 163 ms 38256 KB
s1.txt AC 161 ms 38256 KB
s2.txt AC 161 ms 38256 KB
s3.txt AC 161 ms 38384 KB