-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUVa-12356.cpp
More file actions
47 lines (37 loc) · 1.01 KB
/
UVa-12356.cpp
File metadata and controls
47 lines (37 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <bits/stdc++.h> // here we have all the STL we need, including istringstream and ostringstream
#define ALL(x) x.begin(), x.end()
#define FAST std::cin.tie(0); ios::sync_with_stdio(false); std::cout.tie(0);
using namespace std;
#define endl "\n"
int left1[100001];
int right1[100001];
int main () {
int n, q;
int l, r;
while (scanf("%d %d", &n, &q), (n||q)) {
for (int i = 1; i < n; i++) {
left1[i] = i - 1;
right1[i] = i + 1;
}
left1[1] = -1;
right1[n] = -1;
while (q--) {
scanf("%d %d", &l ,&r);
left1[right1[r]] = left1[l];
if (left1[l] != -1) {
printf("%d", left1[l]);
}
else {
printf("*");
}
right1[left1[l]] = right1[r];
if (right1[r] != -1) {
printf(" %d\n", right1[r]);
}
else {
printf(" *\n");
}
}
printf("-\n");
}
}