jzoj 1151. 【克罗地亚】pjesma

题目描述

“Guess the song” 是一项在克罗地亚的年轻程序员中非常流行的游戏。它是一种集技能、智慧、耐性于一体的游戏。这个游戏给玩游戏的人放音乐,游戏者的目标是竟可能快地猜这首歌的歌名。
Mirko可能不是一个很好的程序员,但他是一个世界级的猜歌者。Mirko总是在专辑里的某首歌播放出至少一半歌词的时候猜出歌名。所有歌名的单词是唯一的(没有一个单词会出现一次或更多次)。
写一个程序,给出歌名和专辑名,看看Mirko在这首歌的哪个点上(在多少个单词之后)猜出歌名。






按题目模拟即可。

代码:

var
  a,s:array[0..10000] of string;
  b:array[0..10000] of boolean;
  n,m,i,j,max:longint;
begin
  readln(n);
  for i:=1 to n do
    readln(s[i]);
  readln(m);
  for i:=1 to m do
    readln(a[i]);
  for i:=1 to m do
    begin
      for j:=1 to n do
        if (a[i]=s[j])and(not b[j]) then
          begin
            inc(max);
            b[j]:=true;
            break;
          end;
      if max>=(n+1) div 2 then
        begin
          writeln(i);
          halt;
        end;
    end;
end.

你可能感兴趣的:(模拟)