var
t, l, i, n, p, j, x, v : integer;
b : boolean;
s : array [1..100] of string;
procedure valid(z : integer);
var
i, j : integer;
a : array [1..100] of string;
b : boolean;
tmp : string;
begin
b := true;
for i := 1 to n do
begin
a[i] := s[i];
a[i][z] := 'A';
end;
for i := 1 to n-1 do
for j := 1 to n-1 do
if a[j] > a[j+1] then
begin
tmp := a[j];
a[j] := a[j+1];
a[j+1] := tmp;
end;
for i := 1 to n-1 do
if a[i] = a[i+1] then
begin
b := false;
break;
end;
if b then
for i := 1 to n do
s[i][z] := 'A';
end;
begin
readln(t);
for l := 1 to t do
begin
readln(p);
readln(n);
for i := 1 to n do
begin
b := true;
s[i] := '';
for j := 1 to p do
begin
read(x);
s[i] := s[i] + char(x+48);
if j > 1 then b := b and (s[j] = s[j-1]);
end;
end;
if (n <> 1) and (not b) then
begin
i := 1;
while (i <= p) and (length(s[1]) <> 1) do
begin
valid(i);
i := i + 1;
end;
v := 0;
for i := 1 to length(s[1]) do
if s[1][i] <> 'A' then v := v + 1;
writeln(v);
end else writeln(1);
end;
end.
The problem definition tells that the output must be the minimum number of active LEDs necessary to display the symbol. But since the only possible symbol doesn't light any, no active LEDs are needed to display it.
Could anyone clarify this output and/or have any ideas for tricky test cases? I've tested my algorithm with the inputs from the forum and some cases of mine, but I keep getting WA-slapped on the face =)
The problem definition tells that the output must be the minimum number of active LEDs necessary to display the symbol. But since the only possible symbol doesn't light any, no active LEDs are needed to display it.
Could anyone clarify this output and/or have any ideas for tricky test cases? I've tested my algorithm with the inputs from the forum and some cases of mine, but I keep getting WA-slapped on the face =)
I am getting a WA.
My algo is to try all the possible permutations. For our answer the bitwise and of all the test cases with the permutation should be distinct