fork download
  1. program results;
  2. const
  3. MAXN = 100000;
  4.  
  5. var
  6. N, i, h : LongInt;
  7. P, R, temp, count : Array[0..MAXN-1] of LongInt;
  8. correttore : char;
  9. begin
  10. {
  11.   uncomment the two following lines if you want to read/write from files
  12.   assign(input, 'input.txt'); reset(input);
  13.   assign(output, 'output.txt'); rewrite(output);
  14. }
  15.  
  16. ReadLn(N);
  17.  
  18. for i:=0 to N-1 do
  19. Read(R[i]);
  20. ReadLn();
  21.  
  22. for i := 0 to N-1 do begin P[i] := 0; temp[i]:=0; count[i]:=0; end;
  23. temp[0]:=1; count[0]:=1; h:=0;
  24. for i:=1 to N-1 do
  25. begin
  26. if R[i]=R[i-1] then count[h]:=count[h]+1
  27. else begin h:=h+1; count[h]:=count[h]+1; temp[h]:=R[i]; end;
  28. end;
  29. for i:=0 to h-1 do if temp[i]=i+1 then correttore:='F'
  30. else correttore:='J'; writeln (correttore);
  31. for i:=0 to h do write(temp[i],' '); writeln;
  32. for i:=0 to h do write(count[i],' '); writeln;
  33. end.
  34.  
  35. for i:=0 to N-1 do
  36. Write(P[i], ' ');
  37. WriteLn();
  38.  
  39. end.
  40.  
Success #stdin #stdout 0s 5288KB
stdin
10
1 1 1 4 4 6 7 8 8 10
stdout
J
1 4 6 7 8 10 
3 2 1 1 2 1