#include #include #include #include using namespace std; int n, m; map > r; typedef map >::iterator iter; iter find_range(int x) { return --r.upper_bound(x); } void print_ranges() { for (iter it = r.begin(); it != r.end(); it++) { cout << '(' << it->first << ", " << it->second.first << " = " << it->second.second << ") "; } cout << endl; } void split(int at) { iter pos = find_range(at); if (pos->first < at) { r[at] = pos->second; pos->second.first = at - 1; } } void modif(int x, int y) { while (x <= y) { split(x); split(y + 1); iter pos = find_range(x); pos->second.second = !pos->second.second; x = pos->second.first + 1; } } void query(int x) { iter left = find_range(x); iter right = left; while (left->first > 1) { iter prev = left; prev--; if (prev->second.second == left->second.second) left = prev; else break; } while (right->second.first < n) { iter next = right; next++; if (next->second.second == right->second.second) right = next; else break; } cout << left->second.second << ' ' << left->first << ' ' << right->second.first << '\n'; } int main() { cin >> n >> m; r[1] = make_pair(n, 0); for (int i = 0; i < m; i++) { int t, x, y; cin >> t >> x; if (t == 1) { cin >> y; modif(x, y); } else { query(x); } //print_ranges(); } }