QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#834613#8722. 卡牌游戏GPT-ofast#Compile Error//Pascal2.1kb2024-12-27 20:57:022024-12-27 20:57:02

Judging History

你现在查看的是最新测评结果

  • [2024-12-27 20:57:02]
  • 评测
  • [2024-12-27 20:57:02]
  • 提交

answer

program ConvertToPascal;

{$APPTYPE CONSOLE}

uses
  SysUtils;

const
  N = 1000009;

var
  a, b, c_, d_, p, tmp: array[1..N] of LongInt;
  n, t: LongInt;

// Function to compare two indices based on c and d arrays
function Compare(x, y: LongInt): Boolean;
begin
  if c_[x] > c_[y] then
    Exit(True)
  else if c_[x] = c_[y] then
    Exit(d_[x] < d_[y])
  else
    Exit(False);
end;

// MergeSort procedure to sort the p array based on the Compare function
procedure MergeSortProc(left, right: LongInt);
var
  mid, i, j, k: LongInt;
begin
  if left >= right then
    Exit;
  
  mid := (left + right) div 2;
  MergeSortProc(left, mid);
  MergeSortProc(mid + 1, right);
  
  i := left;
  j := mid + 1;
  k := left;
  
  while (i <= mid) and (j <= right) do
  begin
    if Compare(p[i], p[j]) then
    begin
      tmp[k] := p[i];
      Inc(i);
    end
    else
    begin
      tmp[k] := p[j];
      Inc(j);
    end;
    Inc(k);
  end;
  
  while i <= mid do
  begin
    tmp[k] := p[i];
    Inc(i);
    Inc(k);
  end;
  
  while j <= right do
  begin
    tmp[k] := p[j];
    Inc(j);
    Inc(k);
  end;
  
  for k := left to right do
    p[k] := tmp[k];
end;

// Procedure to solve each test case
procedure Solve();
var
  i: LongInt;
begin
  Read(n);
  
  for i := 1 to n do
    Read(a[i]);
  
  for i := 1 to n do
    Read(b[i]);
  
  for i := 1 to n do
  begin
    if a[i] < b[i] then
      c_[i] := a[i]
    else
      c_[i] := b[i];
      
    d_[i] := a[i] - b[i];
    p[i] := i;
  end;
  
  // Sort the p array based on the custom comparator
  MergeSortProc(1, n);
  
  // Determine the result based on sorted p array
  if d_[p[1]] < 0 then
    WriteLn('Alice')
  else if (n >= 2) and (c_[p[1]] = c_[p[2]]) then
    WriteLn('Bob')
  else if d_[p[1]] = 0 then
    WriteLn('Alice')
  else if (d_[p[1]] >= 0) and ((n >= 2) and (d_[p[2]] >= 0)) then
    WriteLn('Bob')
  else
    WriteLn('Alice');
end;

// Main program
begin
  ReadLn(t);
  while t > 0 do
  begin
    Solve();
    Dec(t);
  end;
end.

详细

Free Pascal Compiler version 3.0.4+dfsg-23 [2019/11/25] for x86_64
Copyright (c) 1993-2017 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling answer.code
answer.code(3,2) Warning: APPTYPE is not supported by the target OS
answer.code(13,3) Error: Duplicate identifier "N"
answer.code(123,4) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Error: /usr/bin/ppcx64 returned an error exitcode