Subscribed unsubscribe Subscribe Subscribe

0w1

CFR 795 D. Lie or Truth ( Ad hoc )

Problem - D - Codeforces

題意:
給長度 N 的 A, B 數列。問是否可以只任意排列 [ L, R ] 區間內的元素,使得 A = B。

制約:
The first line contains three integers n, l, r (1 ≤ n ≤ 1e5, 1 ≤ l ≤ r ≤ n) — the number of Vasya's cubes and the positions told by Stepan.
The second line contains the sequence a1, a2, ..., an (1 ≤ ai ≤ n) — the sequence of integers written on cubes in the Vasya's order.
The third line contains the sequence b1, b2, ..., bn (1 ≤ bi ≤ n) — the sequence of integers written on cubes after Stepan rearranged their order.

解法:
略。

{$R+,S+,Q+,I+,O-} // なんだろうねこれ
{R-,S-,Q-,I-,O+}
var
  i, N, L, R: Integer;
  A, B: array of Integer;
begin
  readln( N, L, R );
  L := L - 1;
  R := R - 1; // [ L, R ]
  SetLength( A, N );
  SetLength( B, N );
  for i := 0 to N - 1 do read( A[ i ] );
  for i := 0 to N - 1 do read( B[ i ] );
  for i := 0 to N - 1 do
    if ( i < L ) or ( R < i ) then
      if A[ i ] <> B[ i ] then
      begin
        writeln( 'LIE' );
        halt;
      end;
  writeln( 'TRUTH' );
end.