#include <iostream>
using namespace std;
/*
Declarăm și citim variabilele “x” și “n”.
Declaram vectorul “v”
Cu ajutorul unei structuri repetitive “for” citim șirul de “n” numere.
Declaram variabila “count” pe care o initializam cu valoarea zero.
Declaram variabila “start” si “end”.
Cu ajutorul unei structuri repetitive care rulează de la “1” la “n”:
Cu ajutorul unei structuri decizionale comparam elementul curent cu “x”:
In caz afirmativ incrementam “count”.
Prima data cand intalnim valoarea lui x:
Variabila “start” va lua valoarea indicele curent.
“end” se actualizeaza mereu cu valoarea indicelui curent.
Altfel:
Afisam “start” si “end”.
Resetam variabilele “count”, “start” si “end”
*/
int main() {
int x, n;
cin >> x >> n;
int v[21];
for (int i = 1; i <= n; ++i) {
cin >> v[i];
}
int count = 0, start = 0, end;
for (int i = 1; i <= n; ++i) {
if (v[i] == x) {
++count;
if (start == 0) {
start = i;
}
end = i;
} else {
cout << start << " " << end << "\n";
count = 0;
start = 0;
end = 0;
}
}
return 0;
}
/*
4 13
4 1 4 4 2 4 4 4 3 4 4 4 3
1 1
3 4
6 8
10 12
*/
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwovKgpEZWNsYXLEg20gyJlpIGNpdGltIHZhcmlhYmlsZWxlIOKAnHjigJ0gyJlpIOKAnG7igJ0uCkRlY2xhcmFtIHZlY3RvcnVsIOKAnHbigJ0KQ3UgYWp1dG9ydWwgdW5laSBzdHJ1Y3R1cmkgcmVwZXRpdGl2ZSDigJxmb3LigJ0gY2l0aW0gyJlpcnVsIGRlIOKAnG7igJ0gbnVtZXJlLgoKRGVjbGFyYW0gdmFyaWFiaWxhIOKAnGNvdW504oCdIHBlIGNhcmUgbyBpbml0aWFsaXphbSBjdSB2YWxvYXJlYSB6ZXJvLgpEZWNsYXJhbSB2YXJpYWJpbGEg4oCcc3RhcnTigJ0gc2kg4oCcZW5k4oCdLgoKQ3UgYWp1dG9ydWwgdW5laSBzdHJ1Y3R1cmkgcmVwZXRpdGl2ZSBjYX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