NKCARD - Tráo bài
Tác giả: flashmt
Ngôn ngữ: Pascal
var s:ansistring;
n,k,l,i:longint;
c:char;
function find(x,y:longint):longint;
begin
if y=1 then exit(x);
if x=n then exit(find(ord(s[y-1])-64,y-1));
if (s[y-1]='B') and (x=1) then exit(find(x,y-1));
if n-x<y-1 then exit(find(n,y+x-n));
exit(x+y-1);
end;
begin
read(n,k);
s:='';
while not eof do
begin
read(c);
if c='.' then break;
if (c='A') or (c='B') then s:=s+c;
end;
l:=length(s)+1;
writeln(find(k,l)-1,' ',find(k+1,l)-1,' ',find(k+2,l)-1);
end.