# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1043298 |
2024-08-04T07:56:27 Z |
vjudge1 |
Meteors (POI11_met) |
C++17 |
|
5095 ms |
65536 KB |
/*
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣤⣤⣶⣶⣶⣶⠦⠶⡶⢦⠤⠤⠤⣄⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣠⣠⣴⣶⣿⣿⣿⣿⣿⣿⣽⣽⣿⣿⣿⣿⣿⣭⣽⣭⣯⡭⡈⢙⣽⣶⣤⣤⣄⣀⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⣶⣟⣟⣽⣾⣿⢿⣿⡿⣿⣿⣿⣿⣿⣿⣟⠟⡻⣿⣿⣟⣟⣟⣿⡻⠿⠿⠿⠿⣍⠉⠉⠉⠙⠛⠛⠒⠒⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⣶⣿⣿⣿⣿⡿⣾⣿⣯⣿⣿⣿⣽⣿⣷⣽⣿⣿⡿⣿⣿⣾⢿⣿⡷⣿⣿⣿⣿⣯⣭⡅⣠⣹⣢⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣴⣿⡿⣿⣟⣽⣿⣿⣿⣻⣿⣟⣟⣿⣻⣿⣝⣿⣯⣿⣻⣻⣿⣿⣿⣿⡪⡻⣿⣿⣽⣿⣿⣯⣻⣿⣶⣿⣖⣓⡤⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⠿⢿⣿⣟⣿⣿⣻⣿⣿⣿⠿⣿⣿⡿⣿⣿⢿⣿⡯⣿⣛⣿⣕⣿⣿⡿⣿⣿⣷⢿⡿⣻⣿⣿⣿⢿⣿⣿⡻⣿⡷⠷⠯⠦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣼⡽⠹⠩⡝⡇⡿⢻⢻⢻⡛⣿⣹⣿⣿⣿⣿⣿⣽⣿⣯⣿⣿⣿⡿⣿⣿⣿⣿⣽⡿⣿⣯⣻⣿⣿⡿⣿⣿⣿⣿⣿⣝⡍⠩⠀⢘⢄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣏⣓⣂⣀⣀⠀⣜⣀⣀⠐⠐⠓⣞⠨⣿⠿⣗⣿⣿⣻⣿⣿⣽⣿⣿⣺⣿⣿⣿⣿⣻⣿⣿⣿⣝⢿⣛⠻⣻⣿⣟⣟⣿⣿⣿⣤⣐⣒⣚⣳⡀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣿⣿⠟⠻⠽⢯⣌⣶⣿⠿⡡⢴⣾⠛⢀⣷⡉⡟⣷⢊⢘⢀⡙⣷⣾⣿⣿⣿⣿⣿⣿⢿⣿⢿⣿⡿⣿⣿⣽⢋⣝⣿⡿⣿⢿⢿⣛⢿⣿⣗⢇⠟⢦⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢾⣿⣿⣉⣉⣉⣸⣿⣿⣉⣉⢉⣿⠷⠶⠀⢸⣿⣿⢿⠀⠀⠀⠀⢸⠀⢀⡷⣿⣿⣿⢿⡿⡇⣿⣉⢾⣿⣿⠰⢶⡶⣿⣿⣿⣿⣹⣿⡀⠹⣿⣿⡹⣉⢷⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣾⣿⡭⣥⣿⣾⣿⣿⣿⣿⣿⣿⣓⡃⠐⠀⣘⣯⣿⣚⣟⢒⣓⣒⣿⣒⢺⣟⣻⡧⡉⣿⡿⠍⡭⢭⠨⠹⢿⣝⢒⡞⠀⡖⣚⢷⣙⢛⣯⣦⠈⠻⢿⣿⣮⣧⡀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⣿⣿⢩⣿⣿⣿⣾⣷⣿⣿⣿⣟⠒⠀⠐⠀⠉⡿⡟⠉⠹⣿⣟⣳⣶⣆⣴⠑⠀⢳⡄⠈⣷⡁⠁⠈⠀⢈⠙⣷⠀⣀⣀⣀⠀⢨⣷⠀⠊⣟⢣⠀⠀⠉⠛⠿⣿⣄⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⣿⣗⡺⣿⣿⣿⣿⣿⣿⣿⡿⡏⠍⠁⢈⠀⠉⠁⣷⠩⠩⠨⢿⣷⣿⣿⡟⠀⠈⠅⠽⣹⣯⡵⣖⣶⣶⣶⡖⣿⡬⢭⡭⣽⣿⠭⣿⡠⠥⣼⣷⢧⠀⠀⠀⠀⠀⠙⠳⢄⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣟⣿⡏⡃⢀⣠⣬⣶⣶⣦⣍⢀⠈⢸⣘⣧⣿⣿⣏⠀⣀⠀⣃⣷⢿⣼⣽⣆⡲⡦⢵⣾⣿⠃⣧⣿⣿⡼⣿⣿⣇⣻⣿⣘⡆⠀⠀⠀⠀⠀⠀⠈⠛
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢦⣾⠟⠻⠹⢰⣶⣆⡚⢷⡀⠠⠶⡞⣾⣿⠤⠀⠠⡀⢒⡞⠻⣷⠐⢻⣿⣮⡕⣷⣿⡖⣿⣿⣿⡏⣽⣿⣿⢶⣿⣿⢾⡄⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣿⣽⣿⣿⡯⡿⢿⢽⣽⣮⣯⣯⡟⠬⠅⢡⡀⣠⣽⣿⣧⠵⠁⠀⠀⠇⡍⢿⠀⠀⠤⠀⠏⠩⠬⠹⡤⠀⣿⢝⡿⡯⣾⣯⣿⣟⣯⣖⣺⣿⣕⠽⣯⣿⣬⣽⡀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣾⣿⣻⣿⣿⠷⠿⠿⣻⣿⣟⣿⣿⠆⠁⢠⣿⣿⡽⠿⡿⣿⠀⠀⠀⠀⠀⠉⠋⠀⠀⠀⠀⠒⠉⠊⢈⠋⠁⡋⣻⣿⣿⣿⣿⣿⣿⣿⣿⢿⣿⣷⣿⣿⣟⣹⣿⡆⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣾⣿⡿⣿⣿⣿⣿⡭⢹⣿⣿⣻⣽⣿⡀⠀⢨⡇⠉⠍⢌⠼⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠴⣶⢶⠾⢦⣆⠂⠚⣿⣷⣽⡗⣿⡯⣿⠵⢿⣯⣯⣿⣿⣿⣕⣯⣇⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⣯⣿⣗⣿⣿⣿⡓⣒⣛⣽⣿⣿⢿⣯⠥⠀⠈⢶⡂⠐⣾⠆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠉⢙⣿⣌⣮⠽⣿⣍⢯⣻⣻⣯⠭⠥⣯⠬⣿⣿⣿⣟⣿⣻⣾⣏⢹⡀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⣿⣾⣿⣷⣿⣿⡇⡇⠴⣹⣿⣿⣾⣉⢹⣄⡀⠀⠀⠉⠉⠀⠀⠀⠀⠀⠀⣠⡄⠀⠀⠀⠀⣀⣷⣶⣾⣿⣿⠈⠀⡉⣿⢙⣏⢾⣏⡉⡁⡁⣹⣿⣿⣳⣷⣿⣿⢞⣾⡌⡇⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣯⣿⣿⣿⣿⣭⠭⢭⣿⣿⣷⡒⢀⡶⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⡿⠇⠀⠀⠀⠰⡟⣿⢨⠽⢕⡟⠀⠂⣲⡟⠒⢺⣽⣷⣾⡶⠒⣺⣿⣯⣿⣿⣾⢽⣝⣿⠆⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⣿⣿⣿⣿⣟⣿⣿⣿⣧⣚⣾⣚⣿⣿⠬⠤⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠋⠀⠀⠀⠀⠐⣇⠈⢐⢰⡏⠁⠠⢠⡿⠤⣤⣿⣻⣟⣿⠥⣾⣿⣿⣿⣿⣿⣿⡾⡳⣿⡇⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⡷⣿⣿⣿⣿⡿⣽⣿⢿⣿⣿⠶⠾⣿⣿⢉⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠒⠒⠛⠀⠤⠾⣛⣀⣽⣿⣿⣿⣿⣿⡿⣿⣿⣿⣿⣿⣿⣿⣿⣮⣿⡇⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⣯⣿⣿⣿⣿⣫⣫⣿⣿⢕⣿⣭⢹⡿⣿⣷⣐⣀⠂⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠐⣢⣫⣿⣿⣟⣿⣿⣾⣻⣿⣿⣿⣿⣿⣿⣿⣿⣷⢿⡇⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿⣿⣿⣿⣿⣿⢟⢟⣿⣿⣷⡿⣟⢄⣻⡻⣿⣷⡬⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣾⣛⣿⣿⡿⣿⣿⣟⢟⣟⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⡄⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⡿⣿⣿⣿⡗⣽⣿⣿⣿⣿⣕⡽⣍⢯⣿⣿⣿⢅⠠⠀⠀⠀⠀⠉⠙⠂⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣬⣿⣿⣿⣿⣿⣿⣯⢿⣿⣿⡵⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡽⣄⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⡀⠀⠀⠀⠀⢸⣿⣿⠇⢸⣿⣿⣯⣺⣿⣿⣿⣿⣿⣿⣦⢟⣿⣯⣿⣿⣷⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣼⣾⣿⣿⣿⣿⣿⣿⣗⣟⣿⣿⣺⡯⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣺⡆⠀⠀⠀⠀
⠀⠀⠀⠀⢀⣤⣶⣾⣷⣿⣿⣯⣳⡤⣀⣿⡏⠀⢸⣿⣿⣿⣾⠯⣿⣿⣿⣿⣿⣿⣿⢷⣿⣩⠨⠽⡿⣷⣄⠀⠀⠀⠀⠀⠀⠀⣀⣀⣠⣤⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⣿⣿⢏⣀⣻⣿⣿⣿⣿⣿⣿⣿⣾⡿⣿⣯⢿⡀⠀⠀⠀
⠀⢀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣟⣖⢤⣘⣿⣿⣿⣷⣽⣿⣿⣿⣿⣿⣿⣷⣗⣭⡿⣬⣭⡯⣭⣿⣿⣿⣿⣿⣽⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣺⣿⣿⣿⣕⢒⣿⣿⣿⣿⣿⣿⣿⣿⣻⣾⡿⣿⣿⣇⠀⠀⠀
⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣝⢻⡻⣿⣟⣿⢟⡿⣿⣾⣿⣷⣟⢶⠐⢐⣰⣇⣲⣗⣾⢐⣐⣸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢽⣟⢽⣿⡺⢩⣿⣿⣿⣿⣿⣿⣿⣿⣿⣟⡯⡾⣿⢽⡄⠀⠀
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣾⣾⡻⣷⣿⣟⢿⣿⣿⣿⣿⢷⡤⠀⠴⠑⠷⠶⠰⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣯⣻⢿⣿⣿⣿⣿⣿⣿⣿⣻⣿⣯⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣿⢟⢟⢿⣿⠀⠀
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣝⣿⣿⣝⣿⣿⣿⣿⣷⣽⣄⠄⠀⠄⠀⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢝⣿⡆⠙⠿⣿⣿⣿⣿⣺⣺⠟⢰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣗⣟⢽⠈⢿⡆⠀
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⢾⣿⣿⣿⣿⣿⣾⣇⡀⠆⢀⣿⣿⣷⣿⣿⣿⣿⢿⣿⠁⠈⣿⣿⣿⢾⡇⠀⠀⠀⠹⣿⡿⣿⣉⣈⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢏⣏⢾⠀⠀⣇⠀
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣗⣿⣿⣿⣿⣿⣿⣮⡶⣤⣿⣿⣿⣿⣿⣿⣿⡿⣿⡗⠀⠀⠀⠙⢿⣿⣻⠀⠀⠀⠀⠈⣿⡿⣶⣾⣽⣿⡿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣿⡏⠀⠀⣼⠀
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢽⣿⣿⣿⣿⣿⣿⣿⢿⣿⣿⣿⣵⢝⢵⣿⡯⣯⠃⠀⠀⠀⠀⠀⠙⢿⡄⠀⠀⠀⢰⣿⠗⠉⠙⠿⣮⣧⡈⠻⣿⣿⣿⣿⣿⣿⣿⡯⣮⡇⠀⠀⠀⠀
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧⣫⣿⣿⣿⣿⣷⣿⣿⣿⣾⣾⣻⣻⣿⣻⣟⢿⣶⣄⡀⠀⠀⠀⠀⠀⠓⠀⠀⢠⡿⠁⠀⠀⠀⠀⠈⠙⠻⢦⠈⠿⣿⣿⣿⣿⣿⣟⣿⠁⠀⠀⠀⠀
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣿⣾⣾⣿⣿⣿⣿⣾⣿⣿⣷⣽⣾⡿⣷⣤⣀⠀⠀⠀⠀⠀⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠓⠀⠈⠻⣿⣿⣿⣷⡏⠀⠀⠀⠀⠀
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣽⣿⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣿⡿⣿⣷⣆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⢿⣿⡟⠀⠀⠀⠀⠀⠀
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⡿⣻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣾⣾⡿⣷⣆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢿⠃⠀⠀⠀⠀⠀⠀
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢯⣿⣯⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣮⣯⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠋⠀⠀⠀⠀⠀⠀⠀
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣟⣽⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡷⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣽⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣯⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣟⣿⠋⠀
*/
// skibidi rizz
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie()
#define ll long long
#define ull unsigned long long
#define pb push_back
// #define endl "\n"
#define int ll
#define F first
#define S second
#define db double
#define ld long double
#define short unsigned short
#define pii pair<int,int>
using namespace std;
const ll inf = 2e9,MOD=1e9+7,N=3e5+10,MN=1e9+7,lim=1e6;
const long db Pie=acos(-1);
//...and justice for all
int binpow(int a,int p);
struct skibskibidi{
int l,r,ind,ans,need;
};
struct meteoritna{
int l,r,a;
};
int t[N*4],mark[N*4];
void push(int l,int r,int x){
t[x]+=(r-l+1)*mark[x];
t[x]=min(t[x],inf);
if(l==r){
mark[x]=0;
return ;
}
mark[x*2]+=mark[x];
mark[x*2]=min(mark[x*2],inf);
mark[x*2+1]+=mark[x];
mark[x*2+1]=min(mark[x*2+1],inf);
mark[x]=0;
}
void upd(int l,int r,int v,int x,int lx,int rx){
push(lx,rx,x);
if(l<=lx&&rx<=r){
mark[x]+=v;
push(lx,rx,x);
return;
}
if(r<lx||rx<l){
return ;
}
int m=(lx+rx)/2;
upd(l,r,v,x*2,lx,m);
upd(l,r,v,x*2+1,m+1,rx);
// t[x]=t[x*2]+t[x*2+1];
}
int get(int i,int x,int lx,int rx){
push(lx,rx,x);
if(lx==rx){
return t[x];
}
int m=(lx+rx)/2;
if(i<=m){
return get(i,x*2,lx,m);
}
else{
return get(i,x*2+1,m+1,rx);
}
}
const void solve(){
int n,m;
cin>>n>>m;
vector<skibskibidi>q(n+1);
vector<vector<int>>gov(m+1);
for(int i=1;i<=m;i++){
int x;
cin>>x;
gov[x].pb(i);
}
for(int i=1;i<=n;i++){
int x;
cin>>x;
q[i]={0,0,i,-1,x};
}
int k;
cin>>k;
for(int i=1;i<=n;i++){
q[i].l=1;
q[i].r=k;
}
vector<meteoritna>a(k+1);
for(int i=1;i<=k;i++){
cin>>a[i].l>>a[i].r>>a[i].a;
}
for(int gay=0;gay<20;gay++){
vector<vector<int>>g(k+1);
for(int i=1;i<=m*4;i++){
t[i]=0;
mark[i]=0;
}
for(int i=1;i<=n;i++){
int mid=(q[i].l+q[i].r)/2;
g[mid].pb(i);
// cout<<mid<<" ";
}
for(int i=1;i<=k;i++){
if(a[i].l<=a[i].r){
upd(a[i].l,a[i].r,a[i].a,1,1,m);
}
else{
upd(a[i].l,m,a[i].a,1,1,m);
upd(1,a[i].r,a[i].a,1,1,m);
}
// for(int i=1;i<=m;i++){
// cout<<get(i,1,1,m)<<" ";
// }
// cout<<endl;
for(auto to:g[i]){
int sum=0;
for(auto loc:gov[to]){
sum+=get(loc,1,1,m);
sum=min(sum,inf);
// cout<<get(loc,1,1,m)<<" ";
}
// int mid=(q[to].l+q[to].r)/2;
if(sum>=q[to].need){
q[to].ans=i;
q[to].r=i-1;
}
else{
q[to].l=i+1;
}
}
}
}
for(int i=1;i<=n;i++){
if(q[i].ans==-1){
cout<<"NIE"<<endl;
}
else cout<<q[i].ans<<endl;
}
}
main() {
srand(time(NULL));
IOS;
//freopen("c oins.in", "r", stdin);
//freopen("coins.out", "w", stdout);
int UwU=1;
// cin>>UwU;
for(int i=1;i<=UwU;i++) {
// cout<<"Case "<<i<<": ";
solve();
// cout<<endl;
}
cout<<fixed<<setprecision(10);
cerr<<"Time:"<<1000*((double)clock())/(double)CLOCKS_PER_SEC<<"ms\n";
}
// int binmul(int a,int b){}
int binpow(int a,int p){if(p==0)return 1;if(p%2){return ((binpow(a,p-1)*a)%MOD);}int res=binpow(a,p/2)%MOD; return (res*res)%MOD;}
Compilation message
met.cpp:188:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
188 | main() {
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
2648 KB |
Output is correct |
2 |
Correct |
7 ms |
604 KB |
Output is correct |
3 |
Correct |
6 ms |
656 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
604 KB |
Output is correct |
2 |
Correct |
5 ms |
604 KB |
Output is correct |
3 |
Correct |
7 ms |
676 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
448 ms |
8024 KB |
Output is correct |
2 |
Correct |
524 ms |
9484 KB |
Output is correct |
3 |
Correct |
474 ms |
9560 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
461 ms |
9336 KB |
Output is correct |
2 |
Correct |
465 ms |
9336 KB |
Output is correct |
3 |
Correct |
526 ms |
10428 KB |
Output is correct |
4 |
Correct |
140 ms |
7648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
265 ms |
8172 KB |
Output is correct |
2 |
Correct |
404 ms |
9348 KB |
Output is correct |
3 |
Correct |
188 ms |
2920 KB |
Output is correct |
4 |
Correct |
495 ms |
8856 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
463 ms |
7640 KB |
Output is correct |
2 |
Correct |
438 ms |
8248 KB |
Output is correct |
3 |
Correct |
444 ms |
7768 KB |
Output is correct |
4 |
Correct |
526 ms |
9744 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4276 ms |
51872 KB |
Output is correct |
2 |
Correct |
2608 ms |
50540 KB |
Output is correct |
3 |
Correct |
960 ms |
14620 KB |
Output is correct |
4 |
Correct |
5058 ms |
65536 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4143 ms |
51040 KB |
Output is correct |
2 |
Correct |
1684 ms |
49148 KB |
Output is correct |
3 |
Correct |
781 ms |
13316 KB |
Output is correct |
4 |
Correct |
5095 ms |
65536 KB |
Output is correct |