• [1537] Travel

  • 时间限制: 2000 ms 内存限制: 65535 K
  • 问题描述
  • One time, group master organized nekoTeam to travel, he always send a person to toilet before arriving a scene, and the rest of the people continued to move forward.
    The scenes are numbered from 1 to n, nekoTeam was going from scene 1 to scene n.
  • 输入
  • The first line contains an integer T, indicate the number of test cases.
    The first line of each test case contains four integer: n m a b, separated by spaces (1 <= n, a, b <= 40), represents the number of scenes, paths, boys, girls.
    The second line is string consists of n characters, the i-th character indicate the toilet type of the i-th scene, 'A' for men's room, 'B' for women's room.
    The next m lines each contains two positive integers u v, indicate there is a two-way path between scene u and scene v. There is no multiple-paths and self-paths
  • 输出
  • For each test case, if anyone can go to senario n, output "yes", otherwise "no".
  • 样例输入
  • 3
    3 2 2 1
    AAB
    1 2
    2 3
    3 2 1 2
    AAB
    1 2
    2 3
    2 1 1 1
    AA
    1 2
  • 样例输出
  • yes
    no
    no
  • 提示
  • neko13@NWPU
  • 来源
  • 本站或者转载
  • 操作

显示春菜