QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#783154#6312. 城市建造sumairu20 160ms32576kbC++2313.3kb2024-11-26 00:06:402024-11-26 00:06:41

Judging History

你现在查看的是最新测评结果

  • [2024-11-26 00:06:41]
  • 评测
  • 测评结果:20
  • 用时:160ms
  • 内存:32576kb
  • [2024-11-26 00:06:40]
  • 提交

answer

/**
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣤⡤⠤⣤⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡴⠛⠉⠀⠀⠀⠀⠈⠙⢷⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⠟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⣆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣰⠶⣄⡀⠀⠀⠀⢠⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⡏⠀⠀⠉⠛⠶⣤⣸⡇⠀⠀⠀⠀⣀⣤⣶⣶⠒⠒⠒⠶⣬⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣤⠴⠶⣿⠀⠀⠀⠀⠀⠀⠈⠉⠉⠛⠒⠶⢿⣭⣀⡀⢻⡀⠀⠀⢠⡿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣤⠶⠛⠋⠁⠀⠀⢸⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠛⠷⣴⣞⠛⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⡴⠞⠉⠀⠀⠀⠀⠀⠀⢰⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⢦⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⠞⠋⠀⠀⠀⠀⢀⡤⠠⡄⠀⢰⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⠿⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⡞⠁⠀⠀⠀⠀⣠⠖⠋⠀⣸⠇⠀⢸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠀⢀⡀⠀⠀⠀⠀⠀⠀⢦⡀⠀⠀⠀⠸⣷⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡼⠋⠀⠀⠀⠀⢀⣴⠋⢀⢀⡴⠋⠀⢀⣼⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣽⠀⣼⢿⡄⠀⠀⠀⠀⣆⠀⠉⢦⡀⠀⠀⠀⠘⢧⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⡟⠁⠀⠀⠀⠀⣠⠟⠇⠀⠈⠉⠁⠀⣀⣾⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡟⢰⠏⠀⠻⣄⠀⠀⠀⠹⣄⣰⠟⠁⠀⠀⠀⠀⠀⢻⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣾⡟⠀⢀⣀⡖⠀⣰⠏⠀⠀⠀⠀⠀⢀⣼⣿⠋⠸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣧⡟⠀⠀⠀⠹⣦⠀⠀⠀⠀⠁⠀⣶⠀⠀⣴⠛⢧⠀⢻⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣠⠞⣩⡟⠀⠀⠈⠉⠀⢀⡟⠀⠀⢀⣀⣠⣤⣾⡿⠗⠒⠚⣿⠠⣤⠀⠀⠀⠀⠀⠀⠀⢸⣿⠓⠒⠲⠶⠶⠾⢷⣤⣀⣀⠀⠀⠙⣧⠀⠹⣆⣼⠃⠀⢷⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⢀⡴⠟⢁⡼⣿⠁⠀⠀⠀⠀⠀⢸⠃⠀⠀⠈⠉⢠⡾⠋⠀⠀⠀⠀⠸⣆⠙⣧⡀⠀⠀⠀⠀⠀⢸⡇⠀⠀⠀⠀⠀⠀⠀⠻⣆⠉⠁⠀⠀⢹⡄⠀⠈⠁⠀⠀⠘⣷⢦⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⣠⡶⠋⢀⡴⠋⢰⡏⠀⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⣠⠟⠀⠀⠀⠀⠀⠀⠀⢻⡄⢸⣷⣄⠀⠀⠀⠀⢸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠈⢳⣄⠀⠀⠸⣧⠀⠀⠀⠀⠀⠀⢿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⢰⣾⡥⠴⠞⠋⠀⠀⣼⠀⠀⠀⠀⠀⠀⠀⣸⠀⠀⠀⣰⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀⢻⡄⣷⠙⠷⣄⡀⠀⢸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢷⣄⠀⣿⠀⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⣿⡆⠀⠀⠀⠀⠀⠀⢸⡄⠀⣼⢏⣀⣤⣶⣦⣤⣶⣶⣶⣶⣶⣿⣿⣾⡆⠀⠈⠻⢦⣼⡇⢰⣶⣶⣶⣶⣶⣶⣶⣤⣤⣤⣦⠙⢧⣿⠀⠀⠀⠀⠀⠀⢸⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⣿⡇⠀⠀⠀⠀⠀⠀⠘⣇⣼⠏⠘⣿⡿⢿⣿⣿⣿⣿⣿⡏⠉⠉⠉⠙⠃⠀⠀⠀⠀⠉⠁⠘⠛⢻⣿⣿⣿⣿⣿⣟⠛⢛⠷⠀⠀⣿⠀⠀⠀⠀⠀⠀⢸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⡟⣷⠀⠀⠀⠀⠀⠀⠀⢻⡏⠀⠀⠀⠀⣸⣿⣿⣿⣿⣿⣷⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣾⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⢰⡏⠀⠀⠀⠀⠀⠀⣾⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⣷⢹⣆⠀⠀⠀⠀⠀⠀⠈⣷⠀⠀⠀⠀⢹⣿⣿⣿⣿⣿⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⣾⠀⠀⠀⠀⠀⠀⢰⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⢿⠘⣿⣆⠀⠀⠀⠀⠀⠐⠘⣧⠀⠀⠀⠘⢿⣿⣿⣿⣿⠏⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢿⣿⣿⣿⡿⠃⠀⠀⠀⣼⠃⠀⠀⠀⠀⠀⣰⠟⠐⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠸⣇⣿⠙⣧⣄⠀⠀⠀⠀⠀⠘⢧⡀⠀⠀⠈⢹⠿⢟⡋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢻⡿⠀⡀⠀⠀⣼⠃⠀⠀⠀⠀⣀⡾⠋⠀⣴⣷⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⢻⣿⠀⣿⠝⠳⣤⣀⡀⠀⠀⠈⢷⣤⠇⢠⡞⠠⠾⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⠟⠁⡾⠃⣠⡾⠃⠀⠀⣀⣤⠾⠋⠀⠀⠀⡿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣿⣸⣿⠀⠀⠀⠉⠙⠓⡶⠦⠤⣿⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠓⢰⡿⠤⠴⠶⣿⠉⠀⠀⠀⠀⠀⢠⡇⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣿⢻⠀⠀⠀⠀⠀⠃⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢲⣄⠀⠀⠀⠀⠀⠀⠀⢀⣴⠆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡟⠀⠀⠀⠀⠀⠀⢸⡇⣸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⡿⢸⡇⠀⠀⠀⠀⠀⢿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠛⠲⠤⣤⠤⠴⠞⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⡏⠀⠀⠀⠀⠀⠀⢸⠇⠈⣇⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⡇⢸⡇⠀⠀⠀⠀⠀⢸⣿⣦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢿⡇⠀⠀⠀⠀⠀⠀⢺⢀⠀⢿⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⢷⠛⣇⠀⠀⠀⠀⠀⠈⣿⠉⠻⣦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣾⣅⣸⠀⠀⠀⠀⠀⠀⢀⣿⢸⡀⢸⡇⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡿⠘⣀⣿⠀⠀⠀⠀⠀⢷⢸⡄⠀⠈⠙⠶⣤⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⡴⠟⠁⠀⠈⣿⠀⠀⠀⠀⠀⠀⠈⡟⣼⡇⠀⣧⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⡇⠀⢿⢿⠀⠀⠀⠀⠀⠀⠈⣧⠀⠀⠀⠀⠀⠉⠛⠶⢤⣤⣀⣀⠀⣀⡀⠀⠀⠀⠀⠀⢀⣠⡴⠞⠋⠁⠀⠀⠀⠀⢀⡏⠀⠀⠀⠀⠀⠀⢠⡇⢹⣤⠀⢹⡄⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⠀⠀⡿⢸⡆⠀⠀⠀⠀⠀⠀⢻⡆⠀⠀⠀⠀⠀⠀⠀⠀⣿⡿⠟⠋⠉⠁⠀⠀⠀⠀⠀⢸⠁⠀⠀⠀⠀⠀⠀⠀⠀⢸⠇⠀⠀⠀⠀⠀⠀⢸⡇⠈⣟⠀⠈⣷⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⢰⡟⠀⢰⡇⠘⡇⠀⠀⠀⠀⠀⠘⠀⣷⠀⠀⠀⠀⠀⠀⠀⠀⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⡿⠆⠀⠀⠀⠀⠀⠀⣼⠁⠀⢻⡀⠀⠸⣇⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⣼⠁⠀⣼⠁⠀⣿⠀⠀⠀⠀⠀⠀⠀⠻⣇⣀⠀⠀⠀⠀⠀⠀⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡀⠀⠀⠀⠀⠀⠀⠀⣰⡇⠀⠀⠀⠀⠀⠀⠀⣿⡆⠀⠈⣷⡀⠀⢻⡄⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⢰⡇⠀⢀⡏⠀⠀⢻⠀⠀⠀⠀⠀⠀⠀⠀⢻⣦⣄⠀⠀⠀⠀⣠⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣧⠀⠀⠀⠀⠀⣠⣾⣿⠀⠀⠀⠀⠀⠀⢠⣠⡇⡇⠀⠀⠸⣯⡀⠀⢷⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⡾⠀⠀⣼⠁⠀⠀⠸⡇⠀⠀⠀⠀⠀⠀⠀⠀⢿⣽⡧⠴⢶⣿⣿⠖⠒⠛⠛⠃⠀⠀⠀⠚⠋⠉⠉⠉⠙⠓⠲⢾⡛⠻⣽⠃⠀⠀⠀⠀⠀⠀⢸⣿⣃⠀⠀⠀⠀⢹⣷⠀⠘⣧⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣸⠃⠀⢸⡏⠀⠀⠀⢀⣿⠀⠀⠀⠀⢀⣀⠀⠈⠈⢷⠖⠚⠋⠁⢹⡇⠀⢀⣴⠶⠶⢦⣄⣀⣤⡶⠶⠤⠤⠤⠶⠾⠇⢰⡏⠀⠀⠀⠀⠀⠀⠻⣿⣿⣤⡀⠀⠀⠀⠀⢿⣀⠀⠸⣆⠀⠀⠀
⠀⠀⠀⠀⠀⢰⠏⠀⢀⡿⠀⠀⠀⣰⠟⢹⣿⡄⠀⠀⠀⠻⣄⠀⠀⠘⣷⣤⣄⣀⣈⡙⠛⢹⡷⢶⣦⣴⣾⣛⣻⢯⣴⣦⠴⠖⠃⠀⢀⡾⠀⠀⠀⠀⠀⠀⠀⢰⣿⡇⠀⠹⣆⠀⠀⠸⡞⣧⣆⠀⠹⣄⠀⠀
⠀⠀⠀⠀⢠⡟⠀⠀⡼⠁⠀⠀⣰⠏⠀⠈⣟⣧⠀⠀⠀⠀⢻⣆⠀⠀⠈⣧⡿⠀⠈⠉⠛⠛⣻⣿⡿⢿⣿⡍⠉⠀⠀⠀⠀⠀⠀⠀⡾⠁⠀⠀⠀⢀⣴⠀⠀⡾⣿⠁⠀⠀⠘⣧⠀⠀⢿⠘⣟⠀⠀⢻⡄⠀
⠀⠀⢀⣠⡟⠀⢀⡾⠃⠀⠀⣰⡏⠀⠀⠀⣻⠘⣧⠀⠀⠀⠀⢻⣷⡄⠀⠘⢷⡀⠀⠀⠀⠀⠩⣉⠁⠈⣛⡁⠀⠀⠀⠀⠀⠀⣀⣾⠁⠀⠀⣀⣠⣟⠁⠀⣠⣤⡟⠀⠀⠀⠀⠘⣧⡄⠘⡇⠙⣇⠀⠀⠻
*/
#include <bits/stdc++.h>
using namespace std;

#define i64 long long
#define ld long double
#define ull unsigned long long
#define bit(n,i) ((n>>i)&1)
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define FOR(i,a,b) for(int i=a; i<=b; i++)
#define FOD(i,a,b) for(int i=a; i>=b; i--)
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define __sumairu__ signed main()
#define die_hard_onimai_fan void seggs()
#define file(name) if(fopen(name".inp","r")){freopen(name".inp","r",stdin);freopen(name".out","w",stdout);}
#define brute(name) if(fopen(name".inp","r")){freopen(name".inp","r",stdin);freopen(name".ans","w",stdout);}
#define TIME (1.0*clock()/CLOCKS_PER_SEC)
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ai(n) array<int,n>
#define dbg(x) {cout<<#x<<' '<<x<<endl;}
#define dbgF(arr,l,r) {cout<<#arr;FOR(_i,l,r)cout<<' '<<(arr)[_i];cout<<endl;}
#define dbgArr(arr,n) {cout<<#arr;FOR(_i,1,n)cout<<' '<<(arr)[_i];cout<<endl;}
#define el '\n'

template <typename T,typename U>
ostream& operator<<(ostream &os,pair<T,U>p){return os<<"{"<<p.fi<<", "<<p.se<<"}";}
mt19937_64 rd(chrono::steady_clock::now().time_since_epoch().count());

i64 Rand(i64 l,i64 r)
{
    i64 ans=l+rd()%(r-l+1);
    assert(l<=ans&&ans<=r);
    return ans;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
//const i64 base=1e9+7;
//const i64 mod=(1ll<<53)+5;

#define int long long
#define debug 0

//const int mod=1e9+7;
//const int mod=998244353;
const int inf=1e9;
const i64 infl=1e18;
///check the limits, dummy
const int N=1e5+5;

int n,m,k;
int id[N],low[N],com[N],sz[N],st[N],timer,numRoot,top;
bool inst[N];
vector<int>adj[N],nadj[N];
int deg[N];
int val[N];

void dfs(int u,int p=0)
{
    id[u]=low[u]=++timer;
    st[++top]=u;
    inst[u]=1;
    for(int v:adj[u])if(v!=p)
    {
        if(!id[v])
        {
            dfs(v,u);
            low[u]=min(low[u],low[v]);
        }
        else if(inst[v])low[u]=min(low[u],id[v]);
    }
    if(low[u]==id[u])
    {
        ++numRoot;
        int v;
        do
        {
            v=st[top--];
            val[numRoot]++;
            inst[v]=0;
            com[v]=numRoot;
        }
        while(v!=u);
    }
}

int mx[N];
void dfs2(int u,int p=0)
{
    sz[u]=val[u];
    for(int v:nadj[u])if(v!=p)
    {
        dfs2(v,u);
        sz[u]+=sz[v];
        chmax(mx[u],sz[v]);
    }
    chmax(mx[u],n-sz[u]);
}

int rt=-1;
void dfsz(int u,int p=0)
{
    sz[u]=val[u];
    for(int v:nadj[u])if(v!=p)
    {
        dfsz(v,u);
        sz[u]+=sz[v];
    }
}

int ans=1;
bool f[N];
bool check(int lim)
{
//    cout<<lim<<el;
    fill(f+1,f+numRoot+1,0);
    bool yay=1;
    auto dfs=[&](auto&&dfs,int u,int p=0)->void{
        if(sz[u]<lim)return;
        for(int v:nadj[u])if(v!=p)
        {
            dfs(dfs,v,u);
        }

        int sum=val[u];
        bool can=1;
        for(int v:nadj[u])if(v!=p)
        {
            if(sz[v]<lim)sum+=sz[v];
            else if(!f[v])can=0;
        }
//        cout<<u<<' '<<sum<<' '<<can<<el;
        f[u]=(sum==lim&&can);
        if(sz[u]>lim&&!f[u])yay=0;
    };
    dfs(dfs,rt);
//    dbgArr(f,numRoot);
    return f[rt]&&yay;
}

die_hard_onimai_fan
{
    cin>>n>>m>>k;
    set<pii>S;
    FOR(i,1,m)
    {
        int u,v;
        cin>>u>>v;
        if(S.count(minmax(u,v)))continue;
        adj[u].pb(v);
        adj[v].pb(u);
        S.insert(minmax(u,v));
    }
    dfs(1);

    FOR(u,1,n)
    {
        for(int v:adj[u])if(com[u]!=com[v])
        {
//            cout<<com[u]<<' '<<com[v]<<el;
            nadj[com[u]].pb(com[v]);
        }
    }

//    dbgArr(com,n);
//    dbgArr(val,numRoot);

    dfs2(1);
    rt=min_element(mx+1,mx+numRoot+1)-mx;
//    cout<<rt<<el;
    dfsz(rt);

//    dbgArr(sz,numRoot);

    FOR(i,2,n/2)if(n%i==0)ans+=check(i);

    cout<<ans<<el;
//    if(ans>=2)cerr<<" STRONK!";
}

__sumairu__
{
    FAST
    file("cum");

    int tt=1;//cin>>tt;
    while(tt--)seggs();
    cerr<<"\nTime elapsed: "<<TIME<<" s.\n";
}
/**
4 4 1
1 2
2 3
1 3
3 4
*/

詳細信息


Pretests


Final Tests

Test #1:

score: 5
Accepted
time: 1ms
memory: 5916kb

input:

15 20 0
2 7
14 7
11 12
15 9
6 2
11 4
5 10
15 7
8 4
12 5
10 1
14 4
6 8
8 15
7 14
10 14
2 6
13 10
7 13
8 3

output:

1

result:

ok 1 number(s): "1"

Test #2:

score: 5
Accepted
time: 1ms
memory: 6072kb

input:

15 20 0
1 14
5 12
6 1
5 12
9 2
11 10
6 9
11 7
15 3
1 10
8 1
10 15
13 8
3 11
15 11
1 2
8 12
13 4
10 11
4 5

output:

2

result:

ok 1 number(s): "2"

Test #3:

score: 0
Wrong Answer
time: 1ms
memory: 6216kb

input:

20 50 1
11 19
16 2
5 1
15 2
14 16
16 14
16 20
6 7
8 7
19 15
8 7
20 12
14 18
2 15
15 19
4 3
1 8
16 12
18 14
3 9
7 8
13 2
9 17
15 11
4 10
12 20
7 8
8 7
7 8
4 3
8 6
6 8
15 19
2 13
9 17
3 16
8 1
7 8
3 9
3 10
5 1
8 1
5 1
5 1
13 2
7 6
15 19
3 8
3 4
4 10

output:

3

result:

wrong answer 1st numbers differ - expected: '19', found: '3'

Test #4:

score: 0
Wrong Answer
time: 1ms
memory: 6080kb

input:

20 50 1
14 9
20 10
6 19
20 4
11 19
12 2
20 4
14 9
17 9
3 7
9 13
2 3
3 7
19 13
8 15
11 13
14 1
9 5
17 10
9 16
2 12
6 13
2 12
10 17
8 15
18 14
13 6
6 13
9 17
3 7
17 7
6 19
8 7
14 18
9 5
11 13
11 13
2 3
19 13
7 17
9 16
8 7
13 9
11 6
7 8
17 4
5 16
9 17
11 13
7 15

output:

2

result:

wrong answer 1st numbers differ - expected: '8', found: '2'

Test #5:

score: 0
Wrong Answer
time: 1ms
memory: 5924kb

input:

20 50 1
8 17
19 7
19 12
13 3
17 11
13 11
19 7
2 12
17 7
12 7
18 14
9 14
18 16
7 13
8 1
11 13
3 13
12 7
9 16
17 13
3 15
16 9
4 15
11 10
7 17
18 14
20 1
15 13
18 9
11 7
10 6
20 1
17 20
14 16
13 16
20 1
3 15
10 6
1 8
13 16
13 17
16 9
6 10
7 19
12 2
5 6
1 17
15 4
16 7
7 17

output:

1

result:

wrong answer 1st numbers differ - expected: '9', found: '1'

Test #6:

score: 5
Accepted
time: 1ms
memory: 6040kb

input:

200 300 0
35 199
36 155
149 132
176 127
49 2
193 70
103 56
148 152
38 128
2 37
148 7
122 67
19 134
103 19
76 118
52 54
159 51
130 122
107 196
63 172
71 42
174 33
66 170
51 100
102 92
53 106
77 135
103 134
9 52
164 140
185 13
116 138
6 70
69 178
198 23
146 74
87 101
68 194
144 69
105 163
71 78
56 65
...

output:

4

result:

ok 1 number(s): "4"

Test #7:

score: 0
Wrong Answer
time: 1ms
memory: 6064kb

input:

200 300 0
73 128
63 135
186 29
47 95
68 164
145 2
112 171
190 83
82 186
191 124
29 14
104 75
58 133
135 63
39 136
143 181
105 182
174 150
17 193
84 9
143 102
67 182
12 124
99 179
28 107
198 188
63 26
91 94
135 63
54 74
137 150
84 199
18 135
156 88
34 13
200 157
114 156
196 118
81 116
23 10
197 169
1...

output:

1

result:

wrong answer 1st numbers differ - expected: '3', found: '1'

Test #8:

score: 0
Wrong Answer
time: 0ms
memory: 6384kb

input:

2000 1999 1
465 582
845 1459
282 1900
537 152
150 257
1108 710
1144 1451
1262 815
1566 1262
761 439
1265 198
1419 15
480 294
1054 1251
234 367
850 90
344 67
1229 180
1454 1844
1323 1008
1982 348
96 1282
585 919
939 1210
360 437
807 1
757 1533
425 238
138 685
1808 1066
1683 1001
1566 569
1184 1737
11...

output:

2

result:

wrong answer 1st numbers differ - expected: '116891230', found: '2'

Test #9:

score: 0
Wrong Answer
time: 2ms
memory: 6480kb

input:

2000 1999 1
540 1725
1919 242
627 762
695 1264
1377 1351
309 1749
1596 1297
983 1053
260 949
1218 1403
1144 1066
478 1515
1834 688
1525 480
1660 51
374 1207
878 335
833 217
1347 1429
1093 1477
1597 691
803 1081
1059 729
1225 1948
398 1071
1266 1578
1138 631
409 466
1105 1889
57 408
1356 123
1164 104...

output:

1

result:

wrong answer 1st numbers differ - expected: '715143401', found: '1'

Test #10:

score: 0
Wrong Answer
time: 2ms
memory: 6368kb

input:

2000 3000 0
1642 694
947 9
706 385
1 1618
1844 402
442 309
1802 734
333 197
1194 1204
373 1123
891 1281
1907 449
1093 1612
1316 1178
1407 841
708 279
1542 1703
885 1900
1658 971
1493 1908
1299 485
1510 1050
644 958
414 1187
869 1250
1167 495
966 1935
932 468
1769 1260
1040 804
549 1487
620 775
1857 ...

output:

1

result:

wrong answer 1st numbers differ - expected: '4', found: '1'

Test #11:

score: 5
Accepted
time: 2ms
memory: 6636kb

input:

2000 3000 0
408 1484
1521 1118
1045 1938
1090 1897
1432 529
647 1015
1320 1655
1909 1873
1323 989
478 1778
1934 1145
963 1949
871 1716
829 1605
139 860
1757 232
45 1321
1197 627
1634 1366
47 1576
691 1413
1920 252
1366 419
1431 525
439 842
22 1848
536 1479
350 334
663 1412
170 1666
749 1794
149 957
...

output:

5

result:

ok 1 number(s): "5"

Test #12:

score: 0
Wrong Answer
time: 0ms
memory: 6448kb

input:

2000 3000 1
1042 636
1347 1373
16 1538
405 377
1353 1413
139 221
1448 26
797 822
811 880
1380 976
1999 144
1392 1240
1161 886
1740 817
460 263
1519 926
1491 1776
660 1177
1143 702
1377 1526
771 784
893 536
1725 1581
623 584
960 9
1744 1680
1399 351
1975 1290
177 832
1465 1858
541 310
15 369
208 600
...

output:

1

result:

wrong answer 1st numbers differ - expected: '851964567', found: '1'

Test #13:

score: 0
Wrong Answer
time: 2ms
memory: 6416kb

input:

2000 3000 1
399 842
1957 1476
1284 1494
109 1498
1714 1156
533 1573
59 884
1961 1142
600 1179
1557 1380
1468 1541
396 1343
252 629
914 1408
1867 1793
770 1459
1797 1870
1696 282
541 869
1173 1065
980 991
289 1995
765 1343
628 1487
1229 111
555 686
1142 1309
642 1731
809 1498
1828 1134
1954 1151
1768...

output:

1

result:

wrong answer 1st numbers differ - expected: '596182037', found: '1'

Test #14:

score: 0
Wrong Answer
time: 98ms
memory: 27604kb

input:

100000 99999 1
51817 26399
15817 96313
49906 51230
78680 242
31802 66868
30357 78985
12525 6836
21594 17217
51918 70113
34779 36388
39346 27341
23790 83913
67772 74306
79030 8675
13297 48602
31050 35041
88425 8465
2567 50848
32581 25543
17562 66633
50079 89402
21395 31562
82946 75355
36292 48542
178...

output:

1

result:

wrong answer 1st numbers differ - expected: '213549735', found: '1'

Test #15:

score: 0
Wrong Answer
time: 108ms
memory: 27248kb

input:

100000 99999 1
36876 91
57635 85878
73848 6445
56560 31152
92050 83033
84343 84735
19344 59385
16031 82742
24733 35911
28824 52694
89526 7696
47243 72123
7605 41706
40153 16549
117 72375
94514 57348
31759 46680
31370 59666
4180 17810
8025 44622
21906 56373
33740 12923
25841 43798
45198 88125
99159 9...

output:

1

result:

wrong answer 1st numbers differ - expected: '697917401', found: '1'

Test #16:

score: 0
Wrong Answer
time: 131ms
memory: 25408kb

input:

100000 200000 0
73311 26692
47112 50996
80957 18065
55469 44726
18171 14114
1652 41393
33535 58668
10619 90228
62378 80677
78580 22495
20629 89185
98877 21979
36123 37841
20762 58459
28399 29048
94059 29696
88568 84814
57216 16617
48405 54760
1772 58208
78839 23779
56785 90360
71929 74555
89985 4599...

output:

1

result:

wrong answer 1st numbers differ - expected: '7', found: '1'

Test #17:

score: 0
Wrong Answer
time: 160ms
memory: 28596kb

input:

100000 200000 0
74724 58001
2096 36434
10780 66175
8075 91461
98543 76912
91080 58166
91369 63734
86609 37092
76236 17518
27092 86029
49327 96255
55749 32047
59513 4477
21883 24851
12313 11034
58127 78948
38744 21465
52775 15415
26264 19640
80625 57520
96868 34807
46432 91667
34092 71798
48442 53707...

output:

2

result:

wrong answer 1st numbers differ - expected: '4', found: '2'

Test #18:

score: 0
Wrong Answer
time: 148ms
memory: 32576kb

input:

100000 200000 1
41399 84309
59315 57604
76994 41146
89914 5576
10071 2828
40663 32009
8115 72560
15544 30127
75408 15716
13752 40186
49595 42893
93363 66913
35917 59205
4350 58352
84832 39487
93821 1026
52401 33617
90465 3287
16829 33543
86825 73171
69299 16118
35588 53961
58170 44730
50174 71526
44...

output:

1

result:

wrong answer 1st numbers differ - expected: '507071456', found: '1'

Test #19:

score: 0
Wrong Answer
time: 141ms
memory: 29544kb

input:

100000 200000 1
61682 10243
91643 23294
5766 66088
44830 3952
93132 17701
5776 2236
76832 71195
38033 22975
40375 14419
97543 53348
62755 10220
47663 55955
40946 33673
56759 68401
88580 110
62264 25662
214 77675
36373 6940
28023 41926
81352 23162
72657 86572
25487 97838
70762 3628
23027 37780
36529 ...

output:

1

result:

wrong answer 1st numbers differ - expected: '367083003', found: '1'

Test #20:

score: 0
Wrong Answer
time: 131ms
memory: 25716kb

input:

100000 200000 1
83161 92368
783 10781
95621 57345
93279 74412
96084 29764
83839 59585
68295 38546
18951 68761
30461 32813
95888 94000
71796 53643
24398 22834
85633 84908
37566 53874
35140 67126
24519 82526
97616 83915
65640 11899
53812 97833
44761 28536
65548 37212
91762 5827
73676 56073
46769 95173...

output:

2

result:

wrong answer 1st numbers differ - expected: '692564509', found: '2'