• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Problem A - Army buddies

xuanquang1999 Dec 16th, 2014 215 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. const fi = '';
2.       fo = '';
3.       maxN = 100000;
4. var a, prev, next: array [1..maxN] of longint;
5.     n, s: longint;
6.
7. procedure Init;
8. var i: longint;
9. begin
10.  for i:=1 to n do
11.   begin
12.    a[i]:=i;
13.    prev[i]:=i-1;
14.    next[i]:=i+1;
15.   end;
16. end;
17.
18. procedure Work;
19. var i, l, r: longint;
20. begin
21.  for i:=1 to s do
22.   begin
24.    if prev[l] > 0 then next[prev[l]]:=next[r];
25.    if next[r] < n+1 then prev[next[r]]:=prev[l];
26.    if prev[l] = 0 then write('*') else write(prev[l]);
27.    write(' ');
28.    if next[r] = n+1 then write('*') else write(next[r]);
29.    writeln;
30.   end;
31. end;
32.
33. begin
34.  assign(input, fi); reset(input);
35.  assign(output, fo); rewrite(output);
36.
37.  while true do
38.   begin
40.    if eof then break;
41.    Init;
42.    Work;
43.    writeln('-');
44.   end;
45.
46.  close(input); close(output);
47. end.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
Not a member of Pastebin yet?