Please sign in first.
Submission #6335824
Source Code Expand
import sys
input = sys.stdin.readline
from collections import defaultdict
N,M = map(int,input().split())
d_to_LR = defaultdict(list)
for _ in range(N):
L,R = map(int,input().split())
d_to_LR[R-L+1].append((L,R))
def BIT_update(tree,x,value):
while x <= M:
tree[x] += value
x += x & (-x)
def BIT_sum(tree,x):
s = 0
while x:
s += tree[x]
x -= x & (-x)
return s
tree = [0] * (M+1) # BIT で管理。左にあるLの個数 - (R+1)の個数 → いくつの[L,R]に入っているか
long = N # 長すぎて自動回収できる
answer = [0] * (M+1)
for m in range(1,M+1):
for L,R in d_to_LR[m]:
BIT_update(tree,L,1)
BIT_update(tree,R+1,-1)
long -= 1
answer[m] = sum(BIT_sum(tree,x) for x in range(m,M+1,m)) + long
print('\n'.join(map(str, answer[1:])))
Submission Info
| Submission Time | |
|---|---|
| Task | E - Snuke Line |
| User | maspy |
| Language | PyPy3 (2.4.0) |
| Score | 700 |
| Code Size | 875 Byte |
| Status | AC |
| Exec Time | 871 ms |
| Memory | 104412 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 700 / 700 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_example_01.txt, 00_example_02.txt |
| All | 00_example_01.txt, 00_example_02.txt, 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, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_example_01.txt | AC | 161 ms | 38256 KiB |
| 00_example_02.txt | AC | 161 ms | 38256 KiB |
| 01.txt | AC | 160 ms | 38256 KiB |
| 02.txt | AC | 193 ms | 41836 KiB |
| 03.txt | AC | 174 ms | 39152 KiB |
| 04.txt | AC | 161 ms | 38256 KiB |
| 05.txt | AC | 192 ms | 41072 KiB |
| 06.txt | AC | 191 ms | 40944 KiB |
| 07.txt | AC | 160 ms | 38256 KiB |
| 08.txt | AC | 184 ms | 40048 KiB |
| 09.txt | AC | 171 ms | 38768 KiB |
| 10.txt | AC | 165 ms | 38512 KiB |
| 11.txt | AC | 716 ms | 80092 KiB |
| 12.txt | AC | 871 ms | 96988 KiB |
| 13.txt | AC | 635 ms | 68572 KiB |
| 14.txt | AC | 559 ms | 69212 KiB |
| 15.txt | AC | 561 ms | 69084 KiB |
| 16.txt | AC | 684 ms | 77532 KiB |
| 17.txt | AC | 855 ms | 96604 KiB |
| 18.txt | AC | 547 ms | 69468 KiB |
| 19.txt | AC | 856 ms | 96476 KiB |
| 20.txt | AC | 855 ms | 96604 KiB |
| 21.txt | AC | 857 ms | 96604 KiB |
| 22.txt | AC | 864 ms | 96988 KiB |
| 23.txt | AC | 869 ms | 96604 KiB |
| 24.txt | AC | 764 ms | 97116 KiB |
| 25.txt | AC | 567 ms | 74332 KiB |
| 26.txt | AC | 551 ms | 72924 KiB |
| 27.txt | AC | 793 ms | 98140 KiB |
| 28.txt | AC | 592 ms | 73472 KiB |
| 29.txt | AC | 829 ms | 94940 KiB |
| 30.txt | AC | 605 ms | 72028 KiB |
| 31.txt | AC | 742 ms | 104412 KiB |
| 32.txt | AC | 564 ms | 73436 KiB |
| 33.txt | AC | 578 ms | 72668 KiB |
| 34.txt | AC | 750 ms | 102236 KiB |
| 35.txt | AC | 748 ms | 102492 KiB |
| 36.txt | AC | 164 ms | 38384 KiB |
| 37.txt | AC | 390 ms | 68316 KiB |