#include using namespace std; void changeValue(int *vector, int position) { vector[position] = (vector[position] + 1) % 2; } void changeValueOnInterval(int *vector, int lowerBound, int upperBound) { for (int i = lowerBound; i <= upperBound; i++) { changeValue(vector, i); } } int findLowerBoundOfSequence(int *vector, int positonStart) { int position(positonStart - 1); for (; position >= 1 && vector[position] == vector[positonStart]; position--); return ++position; } int findUpperBoundOfSequence(int *vector, int positonStart, int totalNumberOfElements) { int position(positonStart + 1); for (; position <= totalNumberOfElements && vector[position] == vector[positonStart]; position++); return --position; } int *makeSaceForVector(int n) { int *vector = new int[n]; if (!vector) { return NULL; } return vector; } void clean(int **vectorAddress) { delete[] (*vectorAddress); (*vectorAddress) = NULL; } void readAndExecute() { int N, M, *operationVector, operationIndicator, param1, param2; cin >> N >> M; operationVector = makeSaceForVector(N + 1); if (!operationVector) { return; } for (int i = 0; i < M; i++) { cin >> operationIndicator; switch (operationIndicator) { case 1: cin >> param1 >> param2; changeValueOnInterval(operationVector, param1, param2); break; case 2: cin >> param1; cout << operationVector[param1] << " " << findLowerBoundOfSequence(operationVector, param1) << " " << findUpperBoundOfSequence(operationVector, param1, N) << endl; break; } } clean(&operationVector); } int main(void) { readAndExecute(); return 0; }