可达性统计

Luogu
IDLGP10480
Time1000ms
Memory512MB
DifficultyP3
拓扑排序位运算bitset
给定一张 $N$ 个点 $M$ 条边的有向无环图,分别统计从每个点出发能够到达的点的数量。 ## Input 第一行两个整数 $N,M$,接下来 $M$ 行每行两个整数 $x,y$,表示从 $x$ 到 $y$ 的一条有向边。 ## Output 输出共 $N$ 行,表示每个点能够到达的点的数量。 [samples] ## Note 测试数据满足 $1 \le N,M \le 30000$,$1 \le x,y \le N$。
Samples
Input #1
10 10
3 8
2 3
2 5
5 9
5 9
2 3
3 9
4 8
2 10
4 9
Output #1
1
6
3
3
2
1
1
1
1
1
API Response (JSON)
{
  "problem": {
    "name": "可达性统计",
    "description": {
      "content": "给定一张 $N$ 个点 $M$ 条边的有向无环图,分别统计从每个点出发能够到达的点的数量。",
      "description_type": "Markdown"
    },
    "platform": "Luogu",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 524288
    },
    "difficulty": {
      "LuoguStyle": "P3"
    },
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "LGP10480"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "给定一张 $N$ 个点 $M$ 条边的有向无环图,分别统计从每个点出发能够到达的点的数量。\n\n## Input\n\n第一行两个整数 $N,M$,接下来 $M$ 行每行两个整数 $x,y$,表示从 $x$ 到 $y$ 的一条有向边。\n\n## Output\n\n输出共 $N$ 行,表示每个点能够到达的点的数量。\n\n[samples]\n\n## Note\n\n测试数据满足 $1 \\le N,M \\le 3000...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments