blob: 43cabf1d9cce079918f52d575fdb33bce1e6ffad (
plain)
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
|
#include <stdio.h>
int main(){
int s, r;
scanf("%d %d", &s, &r);
while(s>0){
int line[100000]={0}, i;
for(i=0; i<s; i++)
line[i]=1;
int left, right;
while(r--){
int left_seek, right_seek;
scanf("%d %d", &left, &right);
for(i=left-1; i<right; i++)
line[i]=0;
for(left_seek=left-1; line[left_seek]==0
&& left_seek>0; left_seek--);
for(right_seek=right-1; line[right_seek]==0
&& right_seek<s; right_seek++);
if(left_seek<=0 && line[left_seek]==0)
printf("* ");
else
printf("%d ", left_seek+1);
if(right_seek==s && line[right_seek]==0)
printf("*\n");
else
printf("%d\n", right_seek+1);
}
printf("-\n");
scanf("%d %d", &s, &r);
}
}
|