QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#834617 | #8722. 卡牌游戏 | GPT-ofast# | WA | 227ms | 10440kb | Pascal | 2.0kb | 2024-12-27 20:58:50 | 2024-12-27 20:58:50 |
Judging History
answer
const
Nmax = 1000009;
var
a, b, c_, d_, p, tmp: array[1..Nmax] 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.
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 10440kb
input:
5 1 100 100 2 1 1 1 1 2 1 1 0 1 3 1 1 4 5 1 4 10 116 104 101 114 101 32 97 114 101 32 102 105 118 101 32 99 97 115 101 115
output:
Alice Bob Alice Alice Alice
result:
ok 5 lines
Test #2:
score: -100
Wrong Answer
time: 227ms
memory: 8388kb
input:
1000000 1 901418150 815121916 1 455099013 31761433 1 46418945 11466871 1 709189476 658667824 1 977821005 511405192 1 843598992 501074199 1 638564514 680433292 1 994431111 584582554 1 452689372 642414314 1 863578235 135133204 1 438404803 67246919 1 492858783 447116205 1 723252212 948645336 1 19105046...
output:
Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice Alice ...
result:
wrong answer 1st lines differ - expected: 'Bob', found: 'Alice'