답안 #953142

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
953142 2024-03-25T14:41:11 Z TimDee Joker (BOI20_joker) C++17
100 / 100
287 ms 64112 KB
//             _
//   ^ ^      //
// >(O_O)<___//
//   \ __ __  \
//    \\ \\ \\\\
 
#include <bits/stdc++.h>
using namespace std;
 
#pragma GCC optimize("O3")
#pragma GCC target("popcnt")

/*
⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⣳⣳⡳⡳⡳⡳⣳⡳⡳⠳⠷⣳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳
⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⠼⣚⣨⣤⠶⢖⣖⣶⣶⣤⣤⣶⣿⣿⣄⣨⣷⣶⣬⣑⠪⡼⡪⢮⡮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮
⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⢝⡥⣺⣿⣾⣿⣿⣯⣋⣾⣿⣿⣿⣿⣿⣿⣿⣿⣽⣿⣿⣿⣿⣿⣷⣤⠚⣳⣺⢝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝
⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⣣⢚⣵⣿⣿⣿⣿⣿⣿⣿⣿⣿⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠙⢮⡮⡗⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳
⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⠮⡴⠋⣴⣿⡿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣭⣭⣴⣶⣶⣶⣶⣶⣮⣀⡀⠁⠠⠙⢮⣪⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮
⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⡵⠉⡀⡀⡿⢋⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣟⣛⡛⢛⠛⠻⢄⠂⡀⡀⠙⣞⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝
⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⠞⡀⡀⢀⠔⢀⢣⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣼⣷⣞⣝⣣⣜⡤⢤⠠⢌⢷⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⣳⢗⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳
⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢎⠏⡀⡀⣴⠊⡾⣿⡨⣿⣿⣿⣿⣿⣿⣿⣿⣿⠏⣿⣿⣿⣯⣾⣿⣿⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡢⡀⠻⡼⠮⣎⣮⠼⠮⣊⣊⣊⣚⠫⢝⣝⡮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮
⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⡝⡟⡀⡀⣰⡎⣜⣿⣿⣿⣿⣿⣿⣿⠛⢡⠟⣿⡞⣾⣿⣿⣿⣿⣿⣿⣿⣽⣮⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣾⡗⢑⠤⠙⣥⡶⣟⡫⢕⣖⣲⣖⡦⡝⣍⢷⡳⡺⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝
⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡾⡀⡞⣣⣮⣾⣿⣿⣿⣿⣿⡿⣯⡿⣏⣾⣿⢸⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡻⣌⡻⣿⣿⣷⣌⡿⣿⣿⣿⣿⣿⣿⣿⣌⠣⡨⠫⣪⢗⡺⢵⡳⡳⣫⢮⢮⣆⢧⢮⢮⢵⡳⡳⢳⡳⡳⡳⡳⡳⡳⡳⡳⡳
⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⣱⢀⣿⣼⢿⣿⣿⣻⡿⣴⢱⣼⢷⣿⢱⣿⣿⣿⣷⣾⣹⣿⣿⣿⣿⣿⣿⣿⣯⣿⣿⣝⢷⣕⢝⢿⣿⣛⠟⢯⣿⣿⣿⣿⣿⣭⠿⣌⠿⣌⢮⢮⢷⠮⣎⣪⠽⢝⣝⣝⣝⣝⣝⣕⡾⣾⢮⢮⢮⢮⢮⢮⢮⢮⢮
⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⡍⠇⣿⡇⣱⣿⣿⣳⣫⣿⡵⣼⢏⣿⡿⣿⣿⣿⣿⣯⣿⢹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣻⣿⣿⡙⢿⣾⣦⢝⠿⣦⣐⠉⠛⠿⠿⣿⣿⢶⡛⣶⣷⣙⢋⣥⡶⢖⡭⢝⣳⡮⣗⡳⣳⠞⣴⡫⢝⣝⣝⣝⣝⣝⣝⣝⣝
⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⣳⢸⣾⣿⣿⣿⣿⣯⡿⡿⣿⣾⣧⣿⣿⣿⣿⣿⣿⣿⣏⣿⡼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣝⢿⣦⡛⣿⣿⣷⣯⣶⣭⣉⣓⣀⣀⣀⣀⣤⠾⡫⢬⣛⠦⣙⠺⠮⢮⣞⣕⣧⠞⣁⡾⢝⡳⢮⢵⡳⡳⡳⡳⡳⡳⡳
⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⡮⢮⠮⣙⠵⠛⠛⠛⠛⡩⡰⣠⣿⣻⣿⡿⣿⣿⣿⣿⣿⣿⣿⣿⢸⣿⡇⣿⣿⡞⣿⣿⣿⣿⣿⣿⣻⣿⣿⣿⣿⣿⣦⣭⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡑⡯⡗⡺⡳⢦⡭⢍⣛⣖⣺⢯⢵⡳⡳⡫⢝⣝⣕⣪⢮⢮⢮⢮⢮
⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⣝⡝⣕⣪⠗⠋⡀⡀⡀⣠⣖⡰⢺⢼⣿⠻⠟⢋⣮⡾⣫⣿⣿⣿⣿⣿⣿⢸⣿⣷⢹⣿⣷⢿⣿⣿⣿⣿⣿⣿⣷⣍⠻⣿⣿⠿⣿⣿⣿⣿⢿⣆⣿⣿⣿⣿⣿⣿⣿⣿⣌⣗⣪⢮⣝⣝⣝⡮⣞⡮⣝⣝⣕⣪⢮⢮⢗⡳⡳⡫⢝⣝⣝⣝
⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⡳⠓⢵⢿⡇⡄⡀⡀⡀⡀⢰⣃⡶⡸⢕⠢⡙⢿⣞⣻⣿⣿⣿⣿⣿⣿⣿⣿⣿⢸⢮⡌⣷⢿⣿⡌⣿⣿⣿⣿⣿⣿⣿⡿⣿⣶⣬⡙⠦⣙⠻⣿⣿⣌⠜⣿⣿⣿⣷⠙⣿⣷⣝⣦⢳⣫⢵⡳⡳⡫⢝⣝⡳⡳⡳⡳⡫⢝⣝⣝⡮⢮⢮⢗⡳⡳
⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢮⢎⡵⠛⠸⣿⣹⣿⢽⡀⡀⡀⠦⢿⣕⡪⠕⠠⢂⡇⣟⣫⣶⠿⣻⣽⣿⡇⣿⢿⣿⣿⢸⡝⡇⡟⡻⣿⣿⡘⣿⣿⡏⡜⠻⡆⠻⣎⢿⣿⣿⣿⣶⣭⣅⣈⡛⠷⣌⣿⣿⣿⣷⠑⡙⢿⣷⣧⡺⣝⣕⣪⢮⢮⢗⡮⢮⢮⢮⢮⢮⢗⡳⡳⡺⣝⣝⣝⡮
⣝⣝⣝⣝⣝⣝⣝⣝⣝⡽⡋⡟⡀⡀⡀⡀⣿⣯⣿⠇⡀⡀⡀⡀⡀⡀⠛⡄⡂⢐⡁⡀⡀⢈⣾⡾⣻⣿⡇⣿⢸⣿⣿⡞⡇⣿⠘⡹⡹⣿⣷⢪⣿⣿⡟⣳⠉⢮⢦⠳⣌⠿⣿⣿⣿⣍⠻⣿⣿⣶⣤⠻⣿⣿⣿⠱⢲⡙⣿⣎⣷⣗⡳⡫⢝⡵⡳⡺⣝⣝⣝⣝⣝⣝⡮⢮⢮⢵⡳⡳
⡳⡳⡳⡳⡳⡳⠳⣡⠚⢵⠨⣿⡀⡀⡀⠔⢹⣿⣽⡪⡀⡀⡀⡀⡀⡀⡀⠹⡈⢊⡁⣿⠟⣙⣡⣾⣿⣿⡇⣿⠸⣟⣿⢸⣷⣺⡀⢻⢹⡙⣿⣷⠻⣿⡞⡈⢳⡀⠉⠮⣈⢷⡑⡙⣿⣿⣿⣜⣿⣿⣿⣿⣦⠻⢿⣿⣔⡯⢦⠻⡄⢷⣎⣪⢮⣝⡮⢮⢮⢵⡳⡳⡳⡳⡳⡺⣝⣝⣕⣪
⣎⣪⢮⢮⣎⠴⠉⡀⡀⠈⡌⣿⣧⡀⡂⢂⠈⣿⡷⣗⠬⣵⡀⡀⡀⡀⡀⡀⠹⠈⠡⠌⣉⡉⠒⠛⣹⣿⠅⣿⡀⢷⢿⣟⠸⡄⡇⡀⢷⢿⣌⢿⣗⣝⣮⢻⠱⡙⢤⣀⡀⠙⠿⠶⣁⢻⣿⣿⣿⣿⣿⣷⡙⢿⣑⣻⣦⠳⡪⡺⣻⡀⢿⢽⢮⡺⢵⡫⢝⣝⣕⣪⢮⢮⢮⢮⢮⢵⡳⡳
⡳⡳⣫⠛⡀⡀⡀⡀⡀⡀⢻⢿⢿⣷⠈⢀⡅⣿⣿⠡⡱⡏⠂⣷⣀⡀⡀⡀⡀⡹⣿⣿⣶⠶⠚⢁⣿⢸⡆⣿⡇⣗⠸⠈⡄⣿⢹⡀⡀⣳⢻⣷⡙⣆⢦⡓⣷⠈⠓⠬⣙⡻⠭⠛⣛⡉⢷⣿⣿⣿⣿⡘⣿⣷⣬⣒⠽⣶⠤⠛⠾⡀⡼⢯⣝⣕⣪⢗⡺⢵⡳⡳⡫⢝⣝⣝⣝⣝⣕⣪
⡥⠋⡀⡀⡀⡀⡀⡀⡀⡀⡃⢻⣯⣿⣿⡘⡵⢹⣿⠸⢎⢸⢰⣿⣿⣷⣄⡀⡀⡀⡀⠙⣙⠛⣿⣿⣿⡇⡇⣿⣿⢯⡇⡇⣇⠘⣿⡄⠤⠄⠽⡙⣿⣦⢆⠙⣦⣽⣦⣀⡀⣠⣾⣛⣯⠉⠛⣿⣿⣿⣿⠻⡀⡀⠻⣿⣿⣷⠹⢿⡟⡫⢕⢪⡱⡳⡳⣫⢗⡺⣕⣪⢮⢮⢗⡳⡳⡳⡳⡳
⡀⡀⡀⡀⡀⡀⡀⡀⡀⠞⠅⡀⠹⣾⣿⣿⢼⢼⣿⡂⢽⡿⣾⣿⣿⣿⣿⣷⣤⣤⣤⣤⣶⣶⡶⣿⣿⡇⡇⣿⣿⡎⡺⢇⣝⣴⣎⣿⡹⡟⠿⣮⢦⠻⣿⣦⢠⠻⣙⠛⠯⣤⡴⣻⣟⠉⠁⠏⢻⣿⣿⣿⡹⡀⡀⢀⡉⠿⣿⣌⢯⢮⣝⣕⣜⡮⢮⢞⣝⣝⡮⢵⡫⢝⣝⣝⡮⢮⢮⢮
⡀⡀⡀⡀⡀⡀⡀⡀⢘⡑⠎⠢⠔⡴⢹⣿⡌⣿⣿⡇⢆⢃⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⣴⠶⣦⠹⣿⣿⣿⣗⡼⢺⢸⢛⣭⣬⢿⣮⡈⡀⠙⢍⢮⢿⣕⡈⠲⣑⡄⡈⠛⢀⠏⣀⠞⣼⣧⢿⣧⢿⣿⣌⡀⢦⢿⡄⢼⢾⡷⡙⢵⡳⡳⡳⡺⢵⡳⡳⡳⡺⣕⣪⢗⡳⡳⡺⣝⣝
⡀⡀⡀⡀⡀⡀⡀⡀⠇⢅⢢⢂⢋⢯⢇⣿⣿⢸⣿⡧⣼⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣡⡁⣅⠲⣌⡀⣿⣻⣿⣿⢧⣏⡆⣞⠐⠡⣙⣫⢀⠳⣄⡀⠙⢌⠻⣟⠷⣤⣀⣉⠁⡀⡀⡀⡀⡃⡙⣷⣟⡆⣿⣿⣝⣟⣦⣿⣦⢺⣟⣷⡲⡳⡮⢮⢮⣝⣕⣪⢮⢮⢮⢵⡫⢝⡮⢮⢮⢵
⡀⡀⡀⡀⡀⡀⡀⢌⠌⠑⡴⢵⣺⣝⣝⢹⣿⣿⣿⣃⠃⣿⡿⣿⣿⣿⣿⣿⣿⣿⣿⣕⣿⣧⠦⡠⢸⡀⣿⣸⣿⢻⡜⣿⢿⡀⢧⡀⡀⢦⠳⡈⡀⡀⡀⡀⠈⠂⠈⠉⠐⡀⡀⡀⡀⡀⢰⣿⣦⡀⠻⣟⣿⣿⣿⣦⢻⣿⣿⡔⣽⢷⡛⣦⡳⣹⢮⢮⢵⡳⡫⢝⣝⣝⣕⣪⢗⡺⣝⣝
⡀⡀⡀⡀⡀⢀⠢⢊⠌⣞⡮⢮⢗⡳⡳⡂⣿⣿⣿⣿⢸⣿⡼⣿⣿⣿⣿⣿⣿⡿⣰⣿⣿⣿⣿⣄⠪⣹⢸⡯⢿⡈⣷⢻⡎⡄⡀⡄⡀⡀⠑⡀⠑⡀⡀⡀⡀⡀⡀⡀⠃⡀⡀⡀⡀⡀⣾⣿⣿⣟⢷⣬⡻⣦⠻⣿⡙⣿⣿⣿⡈⢯⡹⣷⣭⡲⣙⢬⡫⣗⡮⢮⢗⢳⡳⡳⡫⢝⡮⢵
⡀⡀⡀⡀⠠⠣⢂⢉⢟⡳⡳⡺⣝⣝⡮⢮⢿⣿⣿⣿⣿⡰⢜⣿⣿⣿⣿⣿⡿⣰⣿⣿⣿⣿⣿⣿⣻⣤⡀⣷⡆⣇⢻⡌⣿⢷⡀⠈⡄⡀⡀⡀⡀⡀⡀⡀⡀⡀⡀⡀⡀⡀⡀⡀⡀⡀⣿⣿⣿⣿⣿⣷⣭⡻⢿⣌⢿⣶⡙⣿⣿⡘⡝⣦⢿⣮⣳⣽⣦⡙⠦⣜⡫⠣⣹⡮⢮⢮⢗⡮
⡀⡀⡀⢄⡁⠌⢁⢫⢗⡮⢮⢮⢮⢵⡳⡺⢸⣿⣿⣿⡄⡎⢱⣿⣿⣿⣿⡟⣼⣿⣿⣿⡟⣿⣿⣿⣧⣿⣿⣿⢻⡹⡀⣿⢻⣇⡄⡀⠈⡀⡀⡀⡀⡀⡀⡀⡀⡀⡀⡀⡀⡀⡀⡀⡀⢠⢿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣭⡈⢻⣷⣬⡻⡌⠦⡻⣌⢿⣿⣾⣟⠷⣤⡀⠉⠛⠒⠶⠬⢭⣬
⡀⢀⡌⢌⡱⢡⡣⡹⡳⡳⡺⣝⣝⣝⣕⡪⠄⣿⣿⣿⣇⠌⡿⣿⡿⣿⠟⢼⣿⣿⣿⣿⢰⣿⣿⣿⣿⡹⣿⣿⡎⡀⣧⡘⣇⣿⡸⡀⡀⠈⡄⡀⡀⡀⡀⡀⡀⡀⢀⡄⡀⡀⡀⡀⣠⣿⣿⣶⣙⠻⠿⣿⣿⣛⡻⡿⢿⣿⣿⣦⣙⢟⣶⣾⢟⣋⠻⣌⠿⣿⣿⣿⣶⣽⣳⣶⣤⣄⣀⣀
⢌⡨⢌⣅⣡⡑⣜⣎⣪⢮⢮⢮⢵⡳⡳⢎⠋⣿⣿⣿⣿⢠⠇⢣⣸⠏⢪⣿⣿⣿⣿⡟⣾⣿⣿⣿⣿⣷⣻⣿⣿⢷⡆⣎⠹⣿⣿⢳⡀⡀⠈⢄⡀⡀⡀⡀⡀⠈⡀⡀⡀⡀⣀⣾⣿⣿⣿⣿⣿⡉⡻⣯⣓⠶⢿⣿⣿⣶⣦⣭⣏⠻⣦⡋⣿⣿⣿⣷⠷⣈⠻⣿⣿⣿⣿⣿⣿⣿⡙⠓
⣦⣍⡃⣰⣃⣾⢦⣍⣝⣺⣝⣝⡝⣕⣪⠋⢬⢸⣿⣯⣷⢺⣸⡯⡏⠇⣿⣿⣿⣿⣿⡃⢸⣿⣿⣿⢿⣿⣯⣻⢿⣿⡇⡘⡔⢻⣿⣿⢣⣀⡀⡀⢦⡀⡀⡀⡀⡀⡀⡀⣠⢞⠛⢦⣈⠩⣛⠷⣟⢿⣆⢯⣶⡭⣽⣷⣶⣬⣿⣿⣿⣿⣶⣙⣦⣿⣿⣿⣿⣾⣻⣦⡝⠿⣿⣿⣿⣿⣿⣷
⠪⢱⢖⣲⡺⢛⣼⣿⣿⣿⣿⣿⣿⣿⣶⡈⡿⡀⣿⣿⣽⡀⣿⢇⡯⣼⣿⢯⣿⣿⣿⡀⡆⣿⣿⣎⣧⢿⣿⣧⣿⠞⣿⠙⠘⡔⢻⣿⣿⣧⠻⢶⢤⣃⡀⡀⡀⡀⢀⢞⣺⢗⡳⡳⢬⠻⣷⣍⠲⢝⡮⣳⡙⣷⢾⣯⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡻⠿⣿⣿⣿⣿⣶⣝⠿⣿⣿⣿
⣴⣿⣷⣮⠓⣻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⡷⣯⣿⣿⣿⢷⢻⢸⢡⣿⡿⡇⣿⣿⠇⡀⣿⡜⣿⣿⡄⢷⠻⣽⢿⠘⠸⣳⠱⡌⣆⢻⣿⣿⣷⢸⠨⠵⠻⡙⡖⢾⣱⢎⣕⡸⢮⢼⣫⢧⢖⣍⢿⣦⠲⢝⠿⣦⡙⢯⣝⠟⠿⣷⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣎⢮⣛⢿⣿⣿⣿⣷⣬⣛
⣿⣿⣿⣿⣷⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣮⣻⣿⣿⡯⣦⢼⡟⣿⡇⠅⣿⣿⠐⢷⢿⣜⡈⣿⣝⡄⠙⣭⡸⡀⡀⡀⠙⣜⠮⣷⣿⣿⣿⣷⡁⡀⠁⠓⡁⣃⡀⡟⢧⡹⡬⡎⢸⢱⢼⣗⢯⣬⠻⣌⢮⡲⣍⠷⣍⠿⣷⣤⣀⠋⠹⢗⣣⣝⣛⣛⡛⠻⢿⣿⣽⢯⣲⣝⡻⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣇⣿⣿⣿⣽⣌⠓⠷⠬⣧⣿⠿⢧⣎⣓⢌⠪⢂⣹⠿⡛⣦⣧⡇⠙⢄⡀⡀⠻⣦⡙⣿⣿⣿⣿⣄⢸⡀⡝⡀⢰⢺⣎⠙⠶⣕⠮⣝⠚⠟⢟⣛⠿⠦⡳⡈⠻⣽⣷⣭⡳⣷⣿⣿⡿⣶⣵⣎⣙⠻⠿⢿⣿⣷⣮⣝⠾⣟⣮⡻⣬⡻
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣻⣅⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢾⡾⣿⠟⡀⡀⠈⢀⡀⢄⠻⣓⣿⣿⣿⣿⣮⢀⢿⣹⢳⢫⢋⢱⣼⣦⡚⢻⠉⠁⡀⡀⡀⡎⠈⢮⣮⢦⡛⣿⣿⣿⣶⣬⣙⠛⠦⣔⡢⢬⡭⢍⣍⣛⣛⡛⠷⠾⢿⣭⣷⣝
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢿⣿⢸⣻⣿⣿⣿⡿⣦⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣇⠢⡆⡀⡀⡀⠛⠈⢨⡄⡙⢿⣻⣿⢿⣿⣄⢇⢿⡎⣇⡟⣮⡇⣟⣩⣿⣿⣿⣿⣷⡃⠄⠆⢳⣳⣙⠦⠉⠻⣿⣟⠻⣿⣿⣿⣶⣿⣶⣬⣉⣓⣚⣓⣈⣩⣭⣤⣤⣬
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⣿⢿⣿⣿⣿⡿⣿⣝⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣬⡀⢀⢄⡀⡄⢸⠘⡐⣱⠨⠛⣼⡜⡟⣿⣸⣷⣟⣠⣸⡟⣾⣘⣝⣭⢙⢏⡟⣾⣵⣠⠁⠹⣿⡳⡀⢈⢄⡉⠻⣦⠠⣉⢛⠿⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡹⣿⡹⣿⣿⣿⣿⣿⣞⣿⣶⡻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣤⡀⠈⣌⠘⠽⡜⡀⣯⠹⣙⢿⡟⢿⣹⣯⣿⣱⣧⡟⡿⣴⢟⣵⠟⣿⡿⣭⣿⣆⢠⠻⣿⣮⢷⡀⠛⣾⣔⠩⢛⣜⣝⠿⣮⣽⣻⡿⣿⣿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢻⡞⣿⣿⣿⣿⣮⡻⣿⣬⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣤⣙⠜⡈⡀⡵⢲⣉⣽⠗⢦⣿⣿⣻⣛⣭⡮⣥⢷⣯⣻⣿⣿⡿⣻⣷⣷⣕⢿⣿⣿⣮⢷⣀⠛⣿⣾⣕⠯⣝⡛⠶⣭⣙⣛⣛⣛⣛⣏⣭⣭
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⢻⢻⣿⣿⣿⣿⣿⡳⣝⠿⣷⣍⠻⣿⣿⣿⣿⣿⣯⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡞⣬⣘⡗⢿⢿⣮⢹⠟⢿⡙⣷⡿⣼⢗⣯⣭⣶⣶⣿⣿⣿⣿⣿⣿⣮⠻⣿⣿⣿⣿⣤⠛⢿⣿⣿⣶⣬⣭⣊⣙⠛⠻⣿⣿⣿⣿
⠻⠿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⢧⣿⣿⣿⣿⣿⣿⣿⣿⣷⣝⣿⣦⠙⢿⣿⣿⣿⣿⣎⢹⢿⣿⣿⣿⣿⣿⣿⣽⡿⣿⣿⣶⣿⠫⣿⣿⢿⣾⢧⣧⣿⣿⢟⣋⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣝⡿⣿⣿⣿⣿⣿⣿⣿⣿⢟⣷
⢮⣝⡲⢭⠙⡟⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣞⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣝⢿⣦⡉⠿⣿⣿⣿⣷⣦⣜⠟⢿⣿⣿⣿⣿⣿⣿⣿⣿⡿⣿⣻⣿⢿⢿⣿⣿⣽⣽⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡛⠿⠿⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡷⢿⢟⣝
⡝⣣⣞⣡⢫⣿⣿⣿⣿⣿⣷⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣯⢜⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣬⢻⣷⣌⠻⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⣿⣿⣿⣿⢱⣿⠙⠹⣷⡇⣨⠁⠉⠛⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⣠⣾⣿⣿⡿⡿⡿⢊⣼⣵⣿
⢮⠮⠞⣾⣿⣿⣿⣿⠟⢡⠃⣿⣍⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣞⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣯⢷⡌⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠏⣠⣿⢻⡀⣇⢹⠋⡀⡠⠲⣄⡀⡀⠉⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣟⣯⣶⣶⣺⣿⣭⣶⣾⣿⣿⡿⣫
⣝⠟⣾⣿⣿⣿⠟⣡⢇⠇⣾⣿⣿⣷⡙⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡝⣄⠙⣿⣿⣿⣿⣿⣿⣿⣿⢋⣾⣿⢁⢸⡇⣿⢱⡞⢥⡀⡀⡀⠉⢦⠄⡀⣿⣿⣿⣿⣿⣿⣟⣟⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⣟⣯⣾⠟⣡
⡟⡀⣿⣿⡿⡡⢵⡫⡿⢱⣿⣿⣿⣿⣿⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣞⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣾⣷⡈⢿⣿⣿⣿⣿⣿⣿⣿⡟⡀⡀⢸⡇⣿⢸⡧⡁⡞⠉⠉⠢⣼⣢⡀⠘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣻⣿⣿⣮⡨⡍⢩⣉⣉⣉⠩⠍⣀⠴⣩⢊
⡀⣸⣿⠟⢴⢗⣞⣱⡘⣿⣿⣿⣿⣿⣿⣿⣿⡇⣭⠛⢿⣿⣿⣿⣿⣿⣿⣿⣿⣯⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣟⣦⠹⣿⣿⣿⠠⠈⡀⡀⡑⠁⣿⡇⢸⢸⡇⠎⠌⡵⠤⡀⡀⡀⡀⡀⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⣿⣦⡈⠃⠊⠛⠉⠁⡀⠞⡵⡥
⡀⣿⠏⡺⣝⡵⢃⠏⣾⣿⣿⣿⣿⣿⣿⣿⣿⡇⡏⣗⡯⣖⡤⠻⣿⣿⣿⣿⣿⣿⣿⣻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⣌⢿⣿⡀⡀⡇⡀⡀⣼⣿⡀⢸⡸⡇⠌⠞⡀⣀⡀⠉⠒⣀⡀⡀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⢙⠿⣿⣻⡿⡿⣽⣆⣀⠄⣀⡴⣫⡧⡞
⡀⡟⡫⣗⣳⡎⠟⣾⣿⣿⣿⣿⡿⣿⣿⣿⢹⡇⡇⣫⢧⣕⡪⢕⡙⣿⣿⣿⣿⣿⣿⣿⣮⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣾⣷⣻⡀⡀⡇⡀⡀⠙⡏⠐⣸⡇⠇⠋⢠⠁⡀⠈⠒⡀⣀⠈⡀⠈⣿⣿⣿⣿⣿⣿⣿⣿⡯⢗⡿⢯⢧⡮⢵⢦⡭⡩⣛⣛⣻⡭⡲⡫⢝⣕⣪
⢰⣧⡽⢮⡕⣞⣿⣿⣿⣿⣿⡟⣸⣿⡿⡡⣿⡇⡇⣪⢮⢞⡵⣫⢗⡦⠻⣿⣿⣿⣿⣿⣿⣿⣙⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣽⣷⡀⡇⡀⢠⡰⢁⢠⣿⢸⡀⡇⠈⡀⡟⢄⢄⡀⡀⡀⡀⡀⠈⣿⣿⣿⣿⣿⣿⣿⠱⣡⣾⡇⡜⡜⢝⣝⣏⣪⢮⢮⢮⢮⢮⢮⢮⢗⡳
⠨⣿⢹⡝⣼⣿⣿⣿⣿⣿⠟⢁⣿⠟⢴⡇⣿⡇⡇⢵⢯⢗⢪⢞⣝⡵⡫⢌⢿⣿⣿⣿⣿⣿⣿⢷⡻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⢿⣌⡀⡀⠚⢡⣿⣿⣾⣠⢹⢠⣆⠘⡀⠹⠢⡀⡀⡀⡀⡀⠹⣿⣿⣿⣿⣿⣿⣎⣳⣿⡱⢂⢣⢮⢵⡳⡳⡫⢝⣝⣝⣝⣝⣝⣝⣝
⡸⣿⣆⣜⣿⣿⣿⣿⣿⠏⠎⡿⣡⣗⣜⢀⣿⡇⢇⢺⣝⣝⣝⡵⡳⣫⢮⢮⢇⣟⣿⣿⣿⣿⣿⣿⣿⣜⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠙⣿⣽⣷⡀⡀⢈⣿⢡⡿⠐⡀⠁⢘⠴⡨⠇⢧⠈⠢⠢⠤⡀⡀⠿⣿⣿⣿⣿⣿⣷⣿⣿⣹⣿⣧⢞⣝⣕⣪⢮⢮⢗⡳⡳⡳⡳⡳⡳
⢧⣿⣿⣿⣿⣿⣿⣿⢋⣡⢫⡺⡳⡳⣳⣸⣿⢣⢸⡳⡳⡳⡳⣫⢮⢮⣝⣝⣝⡸⡎⣿⣿⣿⣿⣿⣿⣾⣦⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡀⡀⠙⣯⢿⣦⠃⡀⣾⠇⡀⡀⡀⡂⡇⣱⠆⡀⠳⡁⡄⡀⣴⣭⣌⣠⢻⣿⣿⣿⣿⣿⣸⣸⣿⣿⣆⢗⡳⡳⡫⢝⣝⣝⡮⢮⢮⢮⢮
⠘⣿⣿⣿⣿⣿⣿⣫⢛⣜⣝⣕⣪⢮⠇⣿⣿⢸⣗⡮⢮⢮⢮⢞⣝⣝⡳⡳⡳⣣⢿⡧⣿⣿⣿⣿⣿⣿⣿⣷⡹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡄⡀⡀⠐⠉⠿⣿⣦⣿⡀⢀⡀⡀⠈⣷⣎⠄⠅⡆⠈⠲⣼⣿⣷⣟⠿⠃⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣆⢗⣪⢮⢮⢗⡳⡳⡺⣝⣝⣝
⢾⣿⣿⣿⣿⣿⣿⣌⠚⣳⢳⣳⢗⣳⢰⣿⣿⡟⢯⣗⡯⣝⣝⡵⡳⡳⢼⣪⢮⢮⡈⣿⣽⣻⣿⣿⣿⣿⣿⣿⣿⣎⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡀⡀⡀⠆⡀⡀⢸⡞⢿⣌⡀⡀⡘⢸⢹⢀⢈⢀⠳⢀⣿⣿⠟⡀⠐⡀⡀⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⢮⢝⣝⣝⣝⡮⢮⢮⢵⡳
⠘⣿⣿⣿⣿⡟⠿⣿⣿⣷⣦⣍⡓⠃⣿⣿⡇⠇⠲⠳⠓⢓⣓⣋⣊⣚⡋⠽⡺⣝⡹⠘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧⢿⣿⣿⣿⣿⣿⣿⣿⣿⣆⡀⡀⡀⡀⡀⣿⠁⡀⢈⠻⣶⣌⠘⠼⠨⠥⠸⣈⣾⣿⣿⡀⠐⠠⡱⡀⡀⠈⠿⣿⣿⣿⣿⣿⣿⣿⣿⣧⠳⢳⡳⡳⡳⡺⣝⣝⣕
⢕⢹⣿⢿⣿⣾⡈⡲⢤⣉⣛⠛⠛⣻⣿⣿⢸⢬⡽⠶⣿⣿⣿⢿⣻⣛⡛⠿⣶⣬⣘⠵⢻⣿⢿⣿⣿⣿⣿⣿⣿⣿⣿⡷⠻⣿⣿⣿⣿⣿⣿⣿⣿⡀⡀⡀⠘⢰⡿⡀⡀⠨⡀⡀⠉⠻⠿⣿⣿⣟⣺⣶⠟⣼⣷⠐⠁⠅⠄⡀⡀⠨⢀⢿⣿⣿⣿⣿⣿⣿⢿⣷⠙⢕⡪⢮⢮⢮⢵⡳
⠂⣿⠏⣂⢿⣿⣿⡘⡺⣫⢮⢮⢁⣿⠇⢗⡿⣫⣾⠟⡩⢔⡤⡛⣾⣟⣍⠶⣤⠙⣿⣮⠣⣿⣷⢿⣿⣿⣿⣿⣿⣿⣿⣿⢿⡹⣿⣿⣿⣿⣿⣿⣿⣷⡀⡀⡀⣿⠁⡀⡀⢀⡀⡀⡀⡀⢌⡀⡀⡆⢂⡐⠁⣿⣿⣷⠐⠅⡣⡀⡀⡀⣅⣦⠻⣿⣿⣿⣿⣿⣿⣿⣷⢳⡳⡺⣝⣝⣝⣕
*/

using ll = long long;
#define int long long
#define forn(i,n) for(int i=0; i<(n); ++i)
#define pb push_back
#define pi pair<int,int>
#define f first
#define s second 
#define vii(a,n) vector<int> a(n); forn(i,n) cin>>a[i];
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
 
const ll inf = 1e18;
const ll mod = 998244353;

//types:
#define A 1 //ones to pop()
#define B 0 //ones to push()
struct DSU {
    vector<int> p,sz,d,b;
    int ans=0;
    DSU() {}
    DSU(int n) {
        forn(i,n) p.pb(i),sz.pb(1),d.pb(0),b.pb(0);
    }
    int dist(int u) {
        return p[u]==u ? 0 : (dist(p[u])^d[u]);
    }
    int get(int u) {
        return p[u]==u ? u : get(p[u]);
    }
    struct node {
        int u; //positive - new edge, negative - cycle
        int oldans, oldb;
    };
    vector<node> rb;
    void uni(int u, int v) {
        //cout<<"? uni "<<' '<<u<<' '<<v<<'\n';
        int du=dist(u),dv=dist(v);
        u=get(u),v=get(v);
        if (u==v) {
            rb.pb({-u,ans,b[u]});
            b[u]|=du==dv;
            ans|=b[u];
            return;
        }
        if (sz[u] < sz[v]) swap(u,v);
        rb.pb({v,ans,b[u]});
        p[v]=u;
        d[v]=du^dv^1;
        sz[u]+=sz[v];
        b[u]|=b[v];
    }
    void roll() {
        //cout<<"roll last\n";
        auto it = rb.back(); rb.pop_back();
        int u=it.u, oa=it.oldans, ob=it.oldb;
        if (u < 0) {
            ans = oa;
            b[-u] = ob;
            return;
        }
        int v=p[u];
        sz[v]-=sz[u];
        p[u]=u;
        d[u]=0;
        b[v]=ob;
    }
};
struct q_dsu {
    DSU dsu;
    int size=0;
    q_dsu(int n) {
        dsu = DSU(n);
    }
    vector<pair<pi,int>> st;
    void add(int u, int v, int type) {
        dsu.uni(u,v); size+=type;
        st.pb({{u,v},type});
    }
    void pop() {
        vector<pair<pi,int>> nw,nw2;
        while (st.size() && st.back().s==B) {
            nw.pb(st.back());
            st.pop_back();
        }
        int p=1;
        assert(size);
        while (!(size&p)) p<<=1; //least signif beat
        assert(st.size() >= p);
        forn(it,p) {
            nw2.pb(st.back());
            st.pop_back();
        }
        reverse(all(nw2));
        forn(it,nw.size()+nw2.size()) dsu.roll();
        for(auto&x:nw) {
            st.pb(x);
            dsu.uni(x.f.f,x.f.s);
        }
        for(auto&x:nw2) {
            st.pb(x);
            dsu.uni(x.f.f,x.f.s);
        }
        assert(st.back().s==A);
        dsu.roll();
        st.pop_back();
        --size;
    }
    int query() {
        return dsu.ans;
    }
};

void solve() {

    int n,m,q; cin>>n>>m>>q;
    q_dsu dsu(n+1);
    vector<pi> e(m);
    forn(i,m) cin>>e[i].f>>e[i].s;

    DSU check(n+1);
    forn(i,m) check.uni(e[i].f,e[i].s);
    if (!check.ans) {
        forn(i,q) cout<<"NO\n"; return;
    }

    for(int i=m-1; i>0; --i) dsu.add(e[i].f,e[i].s,A);
    vector<int> f(m);
        
    int r=1;
    for(int i=0; i<m-1; ++i) {
        dsu.add(e[i].f,e[i].s,B);
        //cout<<e[i].f<<' '<<e[i].s<<'\n';
        while (r<m && dsu.query()) {
            ++r; dsu.pop();
            //for(int i=1;i<=n;++i) cout<<dsu.dsu.get(i)<<' '<<dsu.dsu.dist(i)<<' '<<dsu.dsu.b[dsu.dsu.get(i)]<<' '<<dsu.dsu.ans<<'\n';
            //cout<<'\n';
        }
        //cout<<"! "<<i<<": "<<r<<'\n';
        f[i]=r-(dsu.query()^1);
    }
    vector<int> pr(m+1);
    forn(i,m) pr[i+1]=max(pr[i],f[i]);
    DSU z(n+1);
    vector<int> sf(m+1);
    for(int i=m-1; i>=0; --i) {
        z.uni(e[i].f,e[i].s);
        sf[i]=sf[i+1]|z.ans;
    }
    //forn(i,m) cout<<f[i]<<' '; cout<<'\n';

    while (q--) {
        int l,r; cin>>l>>r; --l, --r;
        if (!l) cout<<(sf[r+1] ? "YES\n" : "NO\n");
        else cout<<(pr[l]>r ? "YES\n" : "NO\n");
    }

} 

int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int t=1; 
    //cin>>t;
    while (t--) solve();
    return 0;
}

Compilation message

Joker.cpp:4:1: warning: multi-line comment [-Wcomment]
    4 | //   \ __ __  \
      | ^
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from Joker.cpp:7:
Joker.cpp: In member function 'void q_dsu::pop()':
Joker.cpp:164:26: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<std::pair<long long int, long long int>, long long int> >::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
  164 |         assert(st.size() >= p);
      |                ~~~~~~~~~~^~~~
Joker.cpp:78:33: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<std::pair<long long int, long long int>, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   78 | #define forn(i,n) for(int i=0; i<(n); ++i)
      |                                 ^
Joker.cpp:170:9: note: in expansion of macro 'forn'
  170 |         forn(it,nw.size()+nw2.size()) dsu.roll();
      |         ^~~~
Joker.cpp: In function 'void solve()':
Joker.cpp:78:19: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   78 | #define forn(i,n) for(int i=0; i<(n); ++i)
      |                   ^~~
Joker.cpp:199:9: note: in expansion of macro 'forn'
  199 |         forn(i,q) cout<<"NO\n"; return;
      |         ^~~~
Joker.cpp:199:33: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  199 |         forn(i,q) cout<<"NO\n"; return;
      |                                 ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 456 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 484 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 456 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 484 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 856 KB Output is correct
30 Correct 2 ms 888 KB Output is correct
31 Correct 2 ms 860 KB Output is correct
32 Correct 2 ms 860 KB Output is correct
33 Correct 2 ms 860 KB Output is correct
34 Correct 2 ms 860 KB Output is correct
35 Correct 2 ms 856 KB Output is correct
36 Correct 2 ms 860 KB Output is correct
37 Correct 2 ms 860 KB Output is correct
38 Correct 1 ms 812 KB Output is correct
39 Correct 2 ms 860 KB Output is correct
40 Correct 2 ms 720 KB Output is correct
41 Correct 2 ms 860 KB Output is correct
42 Correct 2 ms 860 KB Output is correct
43 Correct 2 ms 860 KB Output is correct
44 Correct 2 ms 860 KB Output is correct
45 Correct 2 ms 892 KB Output is correct
46 Correct 2 ms 856 KB Output is correct
47 Correct 2 ms 856 KB Output is correct
48 Correct 2 ms 860 KB Output is correct
49 Correct 2 ms 884 KB Output is correct
50 Correct 2 ms 860 KB Output is correct
51 Correct 2 ms 924 KB Output is correct
52 Correct 2 ms 860 KB Output is correct
53 Correct 2 ms 860 KB Output is correct
54 Correct 2 ms 860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 166 ms 54176 KB Output is correct
4 Correct 47 ms 28928 KB Output is correct
5 Correct 193 ms 60428 KB Output is correct
6 Correct 176 ms 54164 KB Output is correct
7 Correct 199 ms 54440 KB Output is correct
8 Correct 182 ms 49108 KB Output is correct
9 Correct 205 ms 50540 KB Output is correct
10 Correct 239 ms 60908 KB Output is correct
11 Correct 184 ms 52184 KB Output is correct
12 Correct 230 ms 59280 KB Output is correct
13 Correct 162 ms 40576 KB Output is correct
14 Correct 189 ms 48600 KB Output is correct
15 Correct 230 ms 55672 KB Output is correct
16 Correct 243 ms 60404 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 456 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 484 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 166 ms 54176 KB Output is correct
30 Correct 47 ms 28928 KB Output is correct
31 Correct 193 ms 60428 KB Output is correct
32 Correct 176 ms 54164 KB Output is correct
33 Correct 199 ms 54440 KB Output is correct
34 Correct 182 ms 49108 KB Output is correct
35 Correct 205 ms 50540 KB Output is correct
36 Correct 239 ms 60908 KB Output is correct
37 Correct 184 ms 52184 KB Output is correct
38 Correct 230 ms 59280 KB Output is correct
39 Correct 162 ms 40576 KB Output is correct
40 Correct 189 ms 48600 KB Output is correct
41 Correct 230 ms 55672 KB Output is correct
42 Correct 243 ms 60404 KB Output is correct
43 Correct 177 ms 49484 KB Output is correct
44 Correct 48 ms 28184 KB Output is correct
45 Correct 191 ms 60268 KB Output is correct
46 Correct 174 ms 49408 KB Output is correct
47 Correct 198 ms 49412 KB Output is correct
48 Correct 208 ms 49416 KB Output is correct
49 Correct 256 ms 61564 KB Output is correct
50 Correct 185 ms 49684 KB Output is correct
51 Correct 202 ms 54224 KB Output is correct
52 Correct 214 ms 62568 KB Output is correct
53 Correct 168 ms 46280 KB Output is correct
54 Correct 204 ms 51204 KB Output is correct
55 Correct 231 ms 55676 KB Output is correct
56 Correct 238 ms 60280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 456 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 484 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 856 KB Output is correct
30 Correct 2 ms 888 KB Output is correct
31 Correct 2 ms 860 KB Output is correct
32 Correct 2 ms 860 KB Output is correct
33 Correct 2 ms 860 KB Output is correct
34 Correct 2 ms 860 KB Output is correct
35 Correct 2 ms 856 KB Output is correct
36 Correct 2 ms 860 KB Output is correct
37 Correct 2 ms 860 KB Output is correct
38 Correct 1 ms 812 KB Output is correct
39 Correct 2 ms 860 KB Output is correct
40 Correct 2 ms 720 KB Output is correct
41 Correct 2 ms 860 KB Output is correct
42 Correct 2 ms 860 KB Output is correct
43 Correct 2 ms 860 KB Output is correct
44 Correct 2 ms 860 KB Output is correct
45 Correct 2 ms 892 KB Output is correct
46 Correct 2 ms 856 KB Output is correct
47 Correct 2 ms 856 KB Output is correct
48 Correct 2 ms 860 KB Output is correct
49 Correct 2 ms 884 KB Output is correct
50 Correct 2 ms 860 KB Output is correct
51 Correct 2 ms 924 KB Output is correct
52 Correct 2 ms 860 KB Output is correct
53 Correct 2 ms 860 KB Output is correct
54 Correct 2 ms 860 KB Output is correct
55 Correct 138 ms 48160 KB Output is correct
56 Correct 44 ms 27936 KB Output is correct
57 Correct 159 ms 58260 KB Output is correct
58 Correct 145 ms 46900 KB Output is correct
59 Correct 193 ms 46844 KB Output is correct
60 Correct 217 ms 58496 KB Output is correct
61 Correct 163 ms 46828 KB Output is correct
62 Correct 199 ms 57200 KB Output is correct
63 Correct 153 ms 40660 KB Output is correct
64 Correct 204 ms 48248 KB Output is correct
65 Correct 233 ms 60232 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 456 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 484 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 856 KB Output is correct
30 Correct 2 ms 888 KB Output is correct
31 Correct 2 ms 860 KB Output is correct
32 Correct 2 ms 860 KB Output is correct
33 Correct 2 ms 860 KB Output is correct
34 Correct 2 ms 860 KB Output is correct
35 Correct 2 ms 856 KB Output is correct
36 Correct 2 ms 860 KB Output is correct
37 Correct 2 ms 860 KB Output is correct
38 Correct 1 ms 812 KB Output is correct
39 Correct 2 ms 860 KB Output is correct
40 Correct 2 ms 720 KB Output is correct
41 Correct 2 ms 860 KB Output is correct
42 Correct 2 ms 860 KB Output is correct
43 Correct 2 ms 860 KB Output is correct
44 Correct 2 ms 860 KB Output is correct
45 Correct 2 ms 892 KB Output is correct
46 Correct 2 ms 856 KB Output is correct
47 Correct 2 ms 856 KB Output is correct
48 Correct 2 ms 860 KB Output is correct
49 Correct 2 ms 884 KB Output is correct
50 Correct 2 ms 860 KB Output is correct
51 Correct 2 ms 924 KB Output is correct
52 Correct 2 ms 860 KB Output is correct
53 Correct 2 ms 860 KB Output is correct
54 Correct 2 ms 860 KB Output is correct
55 Correct 166 ms 54176 KB Output is correct
56 Correct 47 ms 28928 KB Output is correct
57 Correct 193 ms 60428 KB Output is correct
58 Correct 176 ms 54164 KB Output is correct
59 Correct 199 ms 54440 KB Output is correct
60 Correct 182 ms 49108 KB Output is correct
61 Correct 205 ms 50540 KB Output is correct
62 Correct 239 ms 60908 KB Output is correct
63 Correct 184 ms 52184 KB Output is correct
64 Correct 230 ms 59280 KB Output is correct
65 Correct 162 ms 40576 KB Output is correct
66 Correct 189 ms 48600 KB Output is correct
67 Correct 230 ms 55672 KB Output is correct
68 Correct 243 ms 60404 KB Output is correct
69 Correct 177 ms 49484 KB Output is correct
70 Correct 48 ms 28184 KB Output is correct
71 Correct 191 ms 60268 KB Output is correct
72 Correct 174 ms 49408 KB Output is correct
73 Correct 198 ms 49412 KB Output is correct
74 Correct 208 ms 49416 KB Output is correct
75 Correct 256 ms 61564 KB Output is correct
76 Correct 185 ms 49684 KB Output is correct
77 Correct 202 ms 54224 KB Output is correct
78 Correct 214 ms 62568 KB Output is correct
79 Correct 168 ms 46280 KB Output is correct
80 Correct 204 ms 51204 KB Output is correct
81 Correct 231 ms 55676 KB Output is correct
82 Correct 238 ms 60280 KB Output is correct
83 Correct 138 ms 48160 KB Output is correct
84 Correct 44 ms 27936 KB Output is correct
85 Correct 159 ms 58260 KB Output is correct
86 Correct 145 ms 46900 KB Output is correct
87 Correct 193 ms 46844 KB Output is correct
88 Correct 217 ms 58496 KB Output is correct
89 Correct 163 ms 46828 KB Output is correct
90 Correct 199 ms 57200 KB Output is correct
91 Correct 153 ms 40660 KB Output is correct
92 Correct 204 ms 48248 KB Output is correct
93 Correct 233 ms 60232 KB Output is correct
94 Correct 172 ms 54012 KB Output is correct
95 Correct 249 ms 60404 KB Output is correct
96 Correct 192 ms 57984 KB Output is correct
97 Correct 174 ms 53000 KB Output is correct
98 Correct 201 ms 53008 KB Output is correct
99 Correct 194 ms 45096 KB Output is correct
100 Correct 252 ms 60288 KB Output is correct
101 Correct 193 ms 49068 KB Output is correct
102 Correct 205 ms 59792 KB Output is correct
103 Correct 245 ms 64112 KB Output is correct
104 Correct 194 ms 45616 KB Output is correct
105 Correct 256 ms 56412 KB Output is correct
106 Correct 287 ms 57980 KB Output is correct
107 Correct 134 ms 59624 KB Output is correct
108 Correct 201 ms 51364 KB Output is correct
109 Correct 169 ms 50628 KB Output is correct
110 Correct 184 ms 51856 KB Output is correct
111 Correct 184 ms 49848 KB Output is correct
112 Correct 168 ms 50192 KB Output is correct
113 Correct 168 ms 49888 KB Output is correct
114 Correct 170 ms 51604 KB Output is correct
115 Correct 169 ms 49916 KB Output is correct
116 Correct 167 ms 49920 KB Output is correct