Submission #65693338
Source Code Expand
Copy
def li():return list(map(int,input().split()))from atcoder.fenwicktree import FenwickTreen,m=li()l=[]for _ in range(m):a,b=li()if a>b:a,b=b,al.append((a,b))q=int(input())C=[]D=[]for _ in range(q):c,d=li()C.append(c)D.append(d)nn=2*n
def li():return list(map(int,input().split()))
from atcoder.fenwicktree import FenwickTree
n,m=li()
l=[]
for _ in range(m):
a,b=li()
if a>b:
a,b=b,a
l.append((a,b))
q=int(input())
C=[]
D=[]
for _ in range(q):
c,d=li()
C.append(c)
D.append(d)
nn=2*n
end=[0]*(nn+2)
for a,b in l:
end[a]+=1
end[b]+=1
pre=[0]*(nn+2)
for i in range(1,nn+2):
pre[i]=pre[i-1]+end[i]
dev=[]
for j in range(q):
l,r=C[j],D[j]
if l<r:
dev.append((l,r,j))
else:
dev.append((l,nn+1,j))
dev.append((0,r,j))
l.sort(reverse=True)
dev.sort(reverse=True)
ft=FenwickTree(nn+2)
inside=[0]*q
idx=0
for l,r ,id in dev:
while idx<m and l[idx][0]>l:
b=l[idx][1]
ft.add(b,1)
idx+=1
inside[id]+=ft.sum(r-1)
for j in range(q):
l,r=C[j],D[j]
if l<r:
e=pre[r-1]-pre[l]
else:
e=pre[nn]-pre[l]+pre[r-1]-pre[0]
ans=e-2*inside[j]
print(ans)
Submission Info
| Submission Time | |
|---|---|
| Task | F - Chord Crossing |
| User | juten |
| Language | Python (PyPy 3.10-v7.3.12) |
| Score | 0 |
| Code Size | 1003 Byte |
| Status | RE |
| Exec Time | 348 ms |
| Memory | 184956 KB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 525 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_00.txt, 00_sample_01.txt |
| All | 00_sample_00.txt, 00_sample_01.txt, 01_small_00.txt, 01_small_01.txt, 01_small_02.txt, 01_small_03.txt, 01_small_04.txt, 01_small_05.txt, 01_small_06.txt, 01_small_07.txt, 01_small_08.txt, 01_small_09.txt, 02_large_00.txt, 02_large_01.txt, 02_large_02.txt, 02_large_03.txt, 02_large_04.txt, 02_large_05.txt, 02_large_06.txt, 02_large_07.txt, 02_large_08.txt, 02_large_09.txt, 02_large_10.txt, 02_large_11.txt, 02_large_12.txt, 02_large_13.txt, 02_large_14.txt, 02_large_15.txt, 02_large_16.txt, 02_large_17.txt, 02_large_18.txt, 02_large_19.txt, 03_handmade_00.txt, 03_handmade_01.txt, 03_handmade_02.txt, 03_handmade_03.txt, 03_handmade_04.txt, 03_handmade_05.txt, 03_handmade_06.txt, 03_handmade_07.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_00.txt | RE | 127 ms | 84920 KB |
| 00_sample_01.txt | RE | 126 ms | 85200 KB |
| 01_small_00.txt | RE | 239 ms | 139376 KB |
| 01_small_01.txt | RE | 240 ms | 138960 KB |
| 01_small_02.txt | RE | 239 ms | 138972 KB |
| 01_small_03.txt | RE | 238 ms | 139008 KB |
| 01_small_04.txt | RE | 240 ms | 138820 KB |
| 01_small_05.txt | RE | 240 ms | 139216 KB |
| 01_small_06.txt | RE | 240 ms | 139032 KB |
| 01_small_07.txt | RE | 240 ms | 139208 KB |
| 01_small_08.txt | RE | 239 ms | 139092 KB |
| 01_small_09.txt | RE | 241 ms | 138768 KB |
| 02_large_00.txt | RE | 297 ms | 171728 KB |
| 02_large_01.txt | RE | 313 ms | 168992 KB |
| 02_large_02.txt | RE | 296 ms | 165372 KB |
| 02_large_03.txt | RE | 318 ms | 171636 KB |
| 02_large_04.txt | RE | 322 ms | 178376 KB |
| 02_large_05.txt | RE | 288 ms | 158636 KB |
| 02_large_06.txt | RE | 284 ms | 167888 KB |
| 02_large_07.txt | RE | 311 ms | 160396 KB |
| 02_large_08.txt | RE | 284 ms | 169548 KB |
| 02_large_09.txt | RE | 336 ms | 182692 KB |
| 02_large_10.txt | RE | 345 ms | 184164 KB |
| 02_large_11.txt | RE | 345 ms | 183824 KB |
| 02_large_12.txt | RE | 345 ms | 183980 KB |
| 02_large_13.txt | RE | 346 ms | 184276 KB |
| 02_large_14.txt | RE | 345 ms | 184140 KB |
| 02_large_15.txt | RE | 346 ms | 184124 KB |
| 02_large_16.txt | RE | 346 ms | 184008 KB |
| 02_large_17.txt | RE | 347 ms | 184100 KB |
| 02_large_18.txt | RE | 348 ms | 184076 KB |
| 02_large_19.txt | RE | 347 ms | 183900 KB |
| 03_handmade_00.txt | RE | 127 ms | 84896 KB |
| 03_handmade_01.txt | RE | 345 ms | 184776 KB |
| 03_handmade_02.txt | RE | 342 ms | 184160 KB |
| 03_handmade_03.txt | RE | 343 ms | 184956 KB |
| 03_handmade_04.txt | RE | 341 ms | 184048 KB |
| 03_handmade_05.txt | RE | 343 ms | 184276 KB |
| 03_handmade_06.txt | RE | 342 ms | 183860 KB |
| 03_handmade_07.txt | RE | 344 ms | 184656 KB |