/**
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣤⡤⠤⣤⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡴⠛⠉⠀⠀⠀⠀⠈⠙⢷⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⠟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⣆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣰⠶⣄⡀⠀⠀⠀⢠⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⡏⠀⠀⠉⠛⠶⣤⣸⡇⠀⠀⠀⠀⣀⣤⣶⣶⠒⠒⠒⠶⣬⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣤⠴⠶⣿⠀⠀⠀⠀⠀⠀⠈⠉⠉⠛⠒⠶⢿⣭⣀⡀⢻⡀⠀⠀⢠⡿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣤⠶⠛⠋⠁⠀⠀⢸⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠛⠷⣴⣞⠛⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⡴⠞⠉⠀⠀⠀⠀⠀⠀⢰⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⢦⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⠞⠋⠀⠀⠀⠀⢀⡤⠠⡄⠀⢰⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⠿⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⡞⠁⠀⠀⠀⠀⣠⠖⠋⠀⣸⠇⠀⢸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠀⢀⡀⠀⠀⠀⠀⠀⠀⢦⡀⠀⠀⠀⠸⣷⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡼⠋⠀⠀⠀⠀⢀⣴⠋⢀⢀⡴⠋⠀⢀⣼⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣽⠀⣼⢿⡄⠀⠀⠀⠀⣆⠀⠉⢦⡀⠀⠀⠀⠘⢧⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⡟⠁⠀⠀⠀⠀⣠⠟⠇⠀⠈⠉⠁⠀⣀⣾⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡟⢰⠏⠀⠻⣄⠀⠀⠀⠹⣄⣰⠟⠁⠀⠀⠀⠀⠀⢻⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣾⡟⠀⢀⣀⡖⠀⣰⠏⠀⠀⠀⠀⠀⢀⣼⣿⠋⠸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣧⡟⠀⠀⠀⠹⣦⠀⠀⠀⠀⠁⠀⣶⠀⠀⣴⠛⢧⠀⢻⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣠⠞⣩⡟⠀⠀⠈⠉⠀⢀⡟⠀⠀⢀⣀⣠⣤⣾⡿⠗⠒⠚⣿⠠⣤⠀⠀⠀⠀⠀⠀⠀⢸⣿⠓⠒⠲⠶⠶⠾⢷⣤⣀⣀⠀⠀⠙⣧⠀⠹⣆⣼⠃⠀⢷⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⢀⡴⠟⢁⡼⣿⠁⠀⠀⠀⠀⠀⢸⠃⠀⠀⠈⠉⢠⡾⠋⠀⠀⠀⠀⠸⣆⠙⣧⡀⠀⠀⠀⠀⠀⢸⡇⠀⠀⠀⠀⠀⠀⠀⠻⣆⠉⠁⠀⠀⢹⡄⠀⠈⠁⠀⠀⠘⣷⢦⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⣠⡶⠋⢀⡴⠋⢰⡏⠀⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⣠⠟⠀⠀⠀⠀⠀⠀⠀⢻⡄⢸⣷⣄⠀⠀⠀⠀⢸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠈⢳⣄⠀⠀⠸⣧⠀⠀⠀⠀⠀⠀⢿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⢰⣾⡥⠴⠞⠋⠀⠀⣼⠀⠀⠀⠀⠀⠀⠀⣸⠀⠀⠀⣰⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀⢻⡄⣷⠙⠷⣄⡀⠀⢸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢷⣄⠀⣿⠀⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⣿⡆⠀⠀⠀⠀⠀⠀⢸⡄⠀⣼⢏⣀⣤⣶⣦⣤⣶⣶⣶⣶⣶⣿⣿⣾⡆⠀⠈⠻⢦⣼⡇⢰⣶⣶⣶⣶⣶⣶⣶⣤⣤⣤⣦⠙⢧⣿⠀⠀⠀⠀⠀⠀⢸⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⣿⡇⠀⠀⠀⠀⠀⠀⠘⣇⣼⠏⠘⣿⡿⢿⣿⣿⣿⣿⣿⡏⠉⠉⠉⠙⠃⠀⠀⠀⠀⠉⠁⠘⠛⢻⣿⣿⣿⣿⣿⣟⠛⢛⠷⠀⠀⣿⠀⠀⠀⠀⠀⠀⢸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⡟⣷⠀⠀⠀⠀⠀⠀⠀⢻⡏⠀⠀⠀⠀⣸⣿⣿⣿⣿⣿⣷⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣾⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⢰⡏⠀⠀⠀⠀⠀⠀⣾⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⣷⢹⣆⠀⠀⠀⠀⠀⠀⠈⣷⠀⠀⠀⠀⢹⣿⣿⣿⣿⣿⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⣾⠀⠀⠀⠀⠀⠀⢰⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⢿⠘⣿⣆⠀⠀⠀⠀⠀⠐⠘⣧⠀⠀⠀⠘⢿⣿⣿⣿⣿⠏⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢿⣿⣿⣿⡿⠃⠀⠀⠀⣼⠃⠀⠀⠀⠀⠀⣰⠟⠐⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠸⣇⣿⠙⣧⣄⠀⠀⠀⠀⠀⠘⢧⡀⠀⠀⠈⢹⠿⢟⡋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢻⡿⠀⡀⠀⠀⣼⠃⠀⠀⠀⠀⣀⡾⠋⠀⣴⣷⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⢻⣿⠀⣿⠝⠳⣤⣀⡀⠀⠀⠈⢷⣤⠇⢠⡞⠠⠾⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⠟⠁⡾⠃⣠⡾⠃⠀⠀⣀⣤⠾⠋⠀⠀⠀⡿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣿⣸⣿⠀⠀⠀⠉⠙⠓⡶⠦⠤⣿⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠓⢰⡿⠤⠴⠶⣿⠉⠀⠀⠀⠀⠀⢠⡇⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣿⢻⠀⠀⠀⠀⠀⠃⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢲⣄⠀⠀⠀⠀⠀⠀⠀⢀⣴⠆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡟⠀⠀⠀⠀⠀⠀⢸⡇⣸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⡿⢸⡇⠀⠀⠀⠀⠀⢿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠛⠲⠤⣤⠤⠴⠞⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⡏⠀⠀⠀⠀⠀⠀⢸⠇⠈⣇⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⡇⢸⡇⠀⠀⠀⠀⠀⢸⣿⣦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢿⡇⠀⠀⠀⠀⠀⠀⢺⢀⠀⢿⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⢷⠛⣇⠀⠀⠀⠀⠀⠈⣿⠉⠻⣦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣾⣅⣸⠀⠀⠀⠀⠀⠀⢀⣿⢸⡀⢸⡇⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡿⠘⣀⣿⠀⠀⠀⠀⠀⢷⢸⡄⠀⠈⠙⠶⣤⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⡴⠟⠁⠀⠈⣿⠀⠀⠀⠀⠀⠀⠈⡟⣼⡇⠀⣧⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⡇⠀⢿⢿⠀⠀⠀⠀⠀⠀⠈⣧⠀⠀⠀⠀⠀⠉⠛⠶⢤⣤⣀⣀⠀⣀⡀⠀⠀⠀⠀⠀⢀⣠⡴⠞⠋⠁⠀⠀⠀⠀⢀⡏⠀⠀⠀⠀⠀⠀⢠⡇⢹⣤⠀⢹⡄⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⠀⠀⡿⢸⡆⠀⠀⠀⠀⠀⠀⢻⡆⠀⠀⠀⠀⠀⠀⠀⠀⣿⡿⠟⠋⠉⠁⠀⠀⠀⠀⠀⢸⠁⠀⠀⠀⠀⠀⠀⠀⠀⢸⠇⠀⠀⠀⠀⠀⠀⢸⡇⠈⣟⠀⠈⣷⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⢰⡟⠀⢰⡇⠘⡇⠀⠀⠀⠀⠀⠘⠀⣷⠀⠀⠀⠀⠀⠀⠀⠀⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⡿⠆⠀⠀⠀⠀⠀⠀⣼⠁⠀⢻⡀⠀⠸⣇⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⣼⠁⠀⣼⠁⠀⣿⠀⠀⠀⠀⠀⠀⠀⠻⣇⣀⠀⠀⠀⠀⠀⠀⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡀⠀⠀⠀⠀⠀⠀⠀⣰⡇⠀⠀⠀⠀⠀⠀⠀⣿⡆⠀⠈⣷⡀⠀⢻⡄⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⢰⡇⠀⢀⡏⠀⠀⢻⠀⠀⠀⠀⠀⠀⠀⠀⢻⣦⣄⠀⠀⠀⠀⣠⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣧⠀⠀⠀⠀⠀⣠⣾⣿⠀⠀⠀⠀⠀⠀⢠⣠⡇⡇⠀⠀⠸⣯⡀⠀⢷⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⡾⠀⠀⣼⠁⠀⠀⠸⡇⠀⠀⠀⠀⠀⠀⠀⠀⢿⣽⡧⠴⢶⣿⣿⠖⠒⠛⠛⠃⠀⠀⠀⠚⠋⠉⠉⠉⠙⠓⠲⢾⡛⠻⣽⠃⠀⠀⠀⠀⠀⠀⢸⣿⣃⠀⠀⠀⠀⢹⣷⠀⠘⣧⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣸⠃⠀⢸⡏⠀⠀⠀⢀⣿⠀⠀⠀⠀⢀⣀⠀⠈⠈⢷⠖⠚⠋⠁⢹⡇⠀⢀⣴⠶⠶⢦⣄⣀⣤⡶⠶⠤⠤⠤⠶⠾⠇⢰⡏⠀⠀⠀⠀⠀⠀⠻⣿⣿⣤⡀⠀⠀⠀⠀⢿⣀⠀⠸⣆⠀⠀⠀
⠀⠀⠀⠀⠀⢰⠏⠀⢀⡿⠀⠀⠀⣰⠟⢹⣿⡄⠀⠀⠀⠻⣄⠀⠀⠘⣷⣤⣄⣀⣈⡙⠛⢹⡷⢶⣦⣴⣾⣛⣻⢯⣴⣦⠴⠖⠃⠀⢀⡾⠀⠀⠀⠀⠀⠀⠀⢰⣿⡇⠀⠹⣆⠀⠀⠸⡞⣧⣆⠀⠹⣄⠀⠀
⠀⠀⠀⠀⢠⡟⠀⠀⡼⠁⠀⠀⣰⠏⠀⠈⣟⣧⠀⠀⠀⠀⢻⣆⠀⠀⠈⣧⡿⠀⠈⠉⠛⠛⣻⣿⡿⢿⣿⡍⠉⠀⠀⠀⠀⠀⠀⠀⡾⠁⠀⠀⠀⢀⣴⠀⠀⡾⣿⠁⠀⠀⠘⣧⠀⠀⢿⠘⣟⠀⠀⢻⡄⠀
⠀⠀⢀⣠⡟⠀⢀⡾⠃⠀⠀⣰⡏⠀⠀⠀⣻⠘⣧⠀⠀⠀⠀⢻⣷⡄⠀⠘⢷⡀⠀⠀⠀⠀⠩⣉⠁⠈⣛⡁⠀⠀⠀⠀⠀⠀⣀⣾⠁⠀⠀⣀⣠⣟⠁⠀⣠⣤⡟⠀⠀⠀⠀⠘⣧⡄⠘⡇⠙⣇⠀⠀⠻
*/
#include <bits/stdc++.h>
using namespace std;
#define i64 long long
#define ld long double
#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) {cerr<<#x<<' '<<x<<endl;}
#define dbgArr(arr,n) {cerr<<#arr;FOR(_i,1,n)cerr<<' '<<(arr)[_i];cerr<<endl;}
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+1ll*rd()*rd()%(r-l+1);
assert(l<=ans&&ans<=r);
return ans;
}
//const i64 base=1e9+7;
//const i64 mod=(1ll<<53)+5;
#define i64 long long
#define debug 0
const int mod=1e9+7;
//const int mod=998244353;
const int inf=1e9;
///check the limits, dummy
const int N=2e5+5;
bool ans[N],did[N],vis[N];
int n,m;
vector<int>adj[N],mark[N];
i64 s[N];
int p[N],rep[N];
int ord[N];
int fs(int v){ return p[v]<0?v:p[v]=fs(p[v]);}
void uni(int u,int v)
{
u=fs(u),v=fs(v);
if(u==v)return;
if(p[u]>p[v])swap(u,v);
p[u]+=p[v];
s[u]+=s[v];
p[v]=u;
}
void dfs(int u,bool ok)
{
ans[u]&=ok;
for(int v:mark[u])dfs(v,ans[u]);
}
die_hard_onimai_fan
{
cin>>n>>m;
FOR(i,1,n)cin>>s[i];
FOR(i,1,m)
{
int u,v;
cin>>u>>v;
adj[u].pb(v);
adj[v].pb(u);
}
FOR(i,1,n)ord[i]=i;
sort(ord+1,ord+n+1,[&](auto x,auto y){
return s[x]<s[y];
});
FOR(i,1,n)ans[i]=1;
fill(p+1,p+n+1,-1);
FOR(i,1,n)
{
int u=ord[i];
for(int v:adj[u])if(did[v])
{
int w=rep[fs(v)];
if(s[fs(v)]<s[u])ans[w]=0;
if(!vis[w])
{
vis[w]=1;
mark[u].pb(w);
}
}
for(int v:adj[u])if(did[v])vis[rep[fs(v)]]=0;
for(int v:adj[u])if(did[v])uni(u,v);
rep[fs(u)]=u;
did[u]=1;
}
int rt=ord[n];
dfs(rt,ans[rt]);
FOR(i,1,n)cout<<ans[i];
}
__sumairu__
{
FAST
file("");
int tt=1;//cin>>tt;
while(tt--)seggs();
cerr<<"\nTime elapsed: "<<TIME<<" s.\n";
}
/**
4 4
2 2 4 3
1 2
1 3
2 3
3 4
*/
Compilation message
island.cpp: In function 'int main()':
island.cpp:59:53: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
59 | #define file(name) if(fopen(name".inp","r")){freopen(name".inp","r",stdin);freopen(name".out","w",stdout);}
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
island.cpp:164:5: note: in expansion of macro 'file'
164 | file("");
| ^~~~
island.cpp:59:83: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
59 | #define file(name) if(fopen(name".inp","r")){freopen(name".inp","r",stdin);freopen(name".out","w",stdout);}
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
island.cpp:164:5: note: in expansion of macro 'file'
164 | file("");
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
11352 KB |
Output is correct |
2 |
Correct |
2 ms |
11356 KB |
Output is correct |
3 |
Correct |
3 ms |
11356 KB |
Output is correct |
4 |
Correct |
4 ms |
11612 KB |
Output is correct |
5 |
Correct |
6 ms |
11612 KB |
Output is correct |
6 |
Correct |
3 ms |
11612 KB |
Output is correct |
7 |
Correct |
4 ms |
11612 KB |
Output is correct |
8 |
Correct |
3 ms |
11560 KB |
Output is correct |
9 |
Correct |
3 ms |
11612 KB |
Output is correct |
10 |
Correct |
4 ms |
11564 KB |
Output is correct |
11 |
Correct |
4 ms |
11612 KB |
Output is correct |
12 |
Correct |
3 ms |
11612 KB |
Output is correct |
13 |
Correct |
3 ms |
11612 KB |
Output is correct |
14 |
Correct |
3 ms |
11612 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
11352 KB |
Output is correct |
2 |
Correct |
2 ms |
11352 KB |
Output is correct |
3 |
Correct |
90 ms |
27012 KB |
Output is correct |
4 |
Correct |
86 ms |
29268 KB |
Output is correct |
5 |
Correct |
92 ms |
28496 KB |
Output is correct |
6 |
Correct |
112 ms |
29144 KB |
Output is correct |
7 |
Correct |
101 ms |
29016 KB |
Output is correct |
8 |
Correct |
104 ms |
29828 KB |
Output is correct |
9 |
Correct |
79 ms |
28240 KB |
Output is correct |
10 |
Correct |
69 ms |
26492 KB |
Output is correct |
11 |
Correct |
66 ms |
26308 KB |
Output is correct |
12 |
Correct |
89 ms |
27480 KB |
Output is correct |
13 |
Correct |
77 ms |
29524 KB |
Output is correct |
14 |
Correct |
86 ms |
29700 KB |
Output is correct |
15 |
Correct |
85 ms |
35744 KB |
Output is correct |
16 |
Correct |
69 ms |
34900 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
11356 KB |
Output is correct |
2 |
Correct |
109 ms |
24748 KB |
Output is correct |
3 |
Correct |
110 ms |
29212 KB |
Output is correct |
4 |
Correct |
84 ms |
31060 KB |
Output is correct |
5 |
Correct |
73 ms |
29520 KB |
Output is correct |
6 |
Correct |
106 ms |
29268 KB |
Output is correct |
7 |
Correct |
101 ms |
35836 KB |
Output is correct |
8 |
Correct |
96 ms |
35924 KB |
Output is correct |
9 |
Correct |
67 ms |
34952 KB |
Output is correct |
10 |
Correct |
81 ms |
27728 KB |
Output is correct |
11 |
Correct |
97 ms |
27988 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
11368 KB |
Output is correct |
2 |
Correct |
114 ms |
24916 KB |
Output is correct |
3 |
Correct |
114 ms |
29060 KB |
Output is correct |
4 |
Correct |
113 ms |
29268 KB |
Output is correct |
5 |
Correct |
97 ms |
29200 KB |
Output is correct |
6 |
Correct |
98 ms |
29268 KB |
Output is correct |
7 |
Correct |
74 ms |
28228 KB |
Output is correct |
8 |
Correct |
82 ms |
32284 KB |
Output is correct |
9 |
Correct |
83 ms |
22484 KB |
Output is correct |
10 |
Correct |
93 ms |
27728 KB |
Output is correct |
11 |
Correct |
88 ms |
27984 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
11352 KB |
Output is correct |
2 |
Correct |
2 ms |
11356 KB |
Output is correct |
3 |
Correct |
3 ms |
11356 KB |
Output is correct |
4 |
Correct |
4 ms |
11612 KB |
Output is correct |
5 |
Correct |
6 ms |
11612 KB |
Output is correct |
6 |
Correct |
3 ms |
11612 KB |
Output is correct |
7 |
Correct |
4 ms |
11612 KB |
Output is correct |
8 |
Correct |
3 ms |
11560 KB |
Output is correct |
9 |
Correct |
3 ms |
11612 KB |
Output is correct |
10 |
Correct |
4 ms |
11564 KB |
Output is correct |
11 |
Correct |
4 ms |
11612 KB |
Output is correct |
12 |
Correct |
3 ms |
11612 KB |
Output is correct |
13 |
Correct |
3 ms |
11612 KB |
Output is correct |
14 |
Correct |
3 ms |
11612 KB |
Output is correct |
15 |
Correct |
2 ms |
11352 KB |
Output is correct |
16 |
Correct |
2 ms |
11352 KB |
Output is correct |
17 |
Correct |
90 ms |
27012 KB |
Output is correct |
18 |
Correct |
86 ms |
29268 KB |
Output is correct |
19 |
Correct |
92 ms |
28496 KB |
Output is correct |
20 |
Correct |
112 ms |
29144 KB |
Output is correct |
21 |
Correct |
101 ms |
29016 KB |
Output is correct |
22 |
Correct |
104 ms |
29828 KB |
Output is correct |
23 |
Correct |
79 ms |
28240 KB |
Output is correct |
24 |
Correct |
69 ms |
26492 KB |
Output is correct |
25 |
Correct |
66 ms |
26308 KB |
Output is correct |
26 |
Correct |
89 ms |
27480 KB |
Output is correct |
27 |
Correct |
77 ms |
29524 KB |
Output is correct |
28 |
Correct |
86 ms |
29700 KB |
Output is correct |
29 |
Correct |
85 ms |
35744 KB |
Output is correct |
30 |
Correct |
69 ms |
34900 KB |
Output is correct |
31 |
Correct |
3 ms |
11356 KB |
Output is correct |
32 |
Correct |
109 ms |
24748 KB |
Output is correct |
33 |
Correct |
110 ms |
29212 KB |
Output is correct |
34 |
Correct |
84 ms |
31060 KB |
Output is correct |
35 |
Correct |
73 ms |
29520 KB |
Output is correct |
36 |
Correct |
106 ms |
29268 KB |
Output is correct |
37 |
Correct |
101 ms |
35836 KB |
Output is correct |
38 |
Correct |
96 ms |
35924 KB |
Output is correct |
39 |
Correct |
67 ms |
34952 KB |
Output is correct |
40 |
Correct |
81 ms |
27728 KB |
Output is correct |
41 |
Correct |
97 ms |
27988 KB |
Output is correct |
42 |
Correct |
3 ms |
11368 KB |
Output is correct |
43 |
Correct |
114 ms |
24916 KB |
Output is correct |
44 |
Correct |
114 ms |
29060 KB |
Output is correct |
45 |
Correct |
113 ms |
29268 KB |
Output is correct |
46 |
Correct |
97 ms |
29200 KB |
Output is correct |
47 |
Correct |
98 ms |
29268 KB |
Output is correct |
48 |
Correct |
74 ms |
28228 KB |
Output is correct |
49 |
Correct |
82 ms |
32284 KB |
Output is correct |
50 |
Correct |
83 ms |
22484 KB |
Output is correct |
51 |
Correct |
93 ms |
27728 KB |
Output is correct |
52 |
Correct |
88 ms |
27984 KB |
Output is correct |
53 |
Correct |
3 ms |
11352 KB |
Output is correct |
54 |
Correct |
3 ms |
11356 KB |
Output is correct |
55 |
Correct |
2 ms |
11356 KB |
Output is correct |
56 |
Correct |
5 ms |
11964 KB |
Output is correct |
57 |
Correct |
4 ms |
11612 KB |
Output is correct |
58 |
Correct |
4 ms |
11612 KB |
Output is correct |
59 |
Correct |
3 ms |
11612 KB |
Output is correct |
60 |
Correct |
3 ms |
11612 KB |
Output is correct |
61 |
Correct |
3 ms |
11612 KB |
Output is correct |
62 |
Correct |
4 ms |
11612 KB |
Output is correct |
63 |
Correct |
4 ms |
11612 KB |
Output is correct |
64 |
Correct |
3 ms |
11612 KB |
Output is correct |
65 |
Correct |
4 ms |
11612 KB |
Output is correct |
66 |
Correct |
4 ms |
11612 KB |
Output is correct |
67 |
Correct |
95 ms |
31616 KB |
Output is correct |
68 |
Correct |
79 ms |
29360 KB |
Output is correct |
69 |
Correct |
99 ms |
28496 KB |
Output is correct |
70 |
Correct |
98 ms |
29008 KB |
Output is correct |
71 |
Correct |
95 ms |
29008 KB |
Output is correct |
72 |
Correct |
92 ms |
29776 KB |
Output is correct |
73 |
Correct |
77 ms |
27988 KB |
Output is correct |
74 |
Correct |
74 ms |
26312 KB |
Output is correct |
75 |
Correct |
66 ms |
26308 KB |
Output is correct |
76 |
Correct |
97 ms |
27700 KB |
Output is correct |
77 |
Correct |
84 ms |
29472 KB |
Output is correct |
78 |
Correct |
74 ms |
29524 KB |
Output is correct |
79 |
Correct |
85 ms |
35720 KB |
Output is correct |
80 |
Correct |
85 ms |
34864 KB |
Output is correct |
81 |
Correct |
117 ms |
29264 KB |
Output is correct |
82 |
Correct |
114 ms |
29268 KB |
Output is correct |
83 |
Correct |
88 ms |
31060 KB |
Output is correct |
84 |
Correct |
78 ms |
29524 KB |
Output is correct |
85 |
Correct |
110 ms |
29264 KB |
Output is correct |
86 |
Correct |
118 ms |
35876 KB |
Output is correct |
87 |
Correct |
102 ms |
35924 KB |
Output is correct |
88 |
Correct |
82 ms |
27668 KB |
Output is correct |
89 |
Correct |
85 ms |
27780 KB |
Output is correct |
90 |
Correct |
121 ms |
29520 KB |
Output is correct |
91 |
Correct |
120 ms |
29264 KB |
Output is correct |
92 |
Correct |
113 ms |
29124 KB |
Output is correct |
93 |
Correct |
106 ms |
29288 KB |
Output is correct |
94 |
Correct |
99 ms |
29264 KB |
Output is correct |
95 |
Correct |
73 ms |
28224 KB |
Output is correct |
96 |
Correct |
71 ms |
32336 KB |
Output is correct |
97 |
Correct |
71 ms |
22352 KB |
Output is correct |
98 |
Correct |
98 ms |
27728 KB |
Output is correct |
99 |
Correct |
91 ms |
28024 KB |
Output is correct |
100 |
Correct |
34 ms |
15704 KB |
Output is correct |
101 |
Correct |
119 ms |
29240 KB |
Output is correct |
102 |
Correct |
83 ms |
27732 KB |
Output is correct |
103 |
Correct |
106 ms |
28244 KB |
Output is correct |
104 |
Correct |
116 ms |
29528 KB |
Output is correct |