比赛 |
顾研NOIP2011模拟赛 |
评测结果 |
AAAATAAAAT |
题目名称 |
项链 |
最终得分 |
80 |
用户昵称 |
Rotide |
运行时间 |
2.301 s |
代码语言 |
Pascal |
内存使用 |
0.17 MiB |
提交时间 |
2012-10-17 19:46:47 |
显示代码纯文本
var
numstate: array['A'..'Z'] of longint = (1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432);
e: array[1..26] of longint;
n, i, ans, j, temp: longint;
str: string;
procedure find(now, count, k: longint);
var
i: longint;
begin
if (count + n - now + 1) <= ans then exit;
if (k xor e[now] = 0) and (count + 1 > ans) then
ans := count + 1;
for i := now + 1 to n do
begin
find(i, count, k);
find(i, count + 1, k xor e[now]);
end;
end;
begin
assign(input, 'necklaced.in'); reset(input);
assign(output, 'necklaced.out'); rewrite(output);
readln(n);
for i := 1 to n do
begin
readln(str);
temp := 0;
for j := 1 to length(str) do
inc(temp, numstate[str[j]]);
e[i] := temp;
end;
ans := 0;
find(1, 0, 0);
write(ans);
close(input); close(output);
end.