<s>运行_v 出来_v 结果_n 对_a 了_y 为什么_r 提交_v 到_v PAT_nx 上_f 去_v 一_m 个_q 测试点_n 过_v 不_d 了_v</s>
<s>引用_v 4_m 楼_n coo135_nx 的_u 回复_vn :_w 智商_n 有限_a ，_w 这_r 道_q 题目_n 实在_d 是_v 看_v 不_d 懂_v 啊_y …_w …_w</s><s>能_v 弄_v 明白_a 在_d 讲_v 什么_r 的_u 真_d 是_v 神仙_n 啊_y ！_w</s><s>！！_w</s><s>百度_n 到_v 有_v 位_q 神仙_n 他_r 明白_v ，_w 解释_v 如下_v ：_w 解决_v 问题_n 的_u 关键_n 是_v 第二_m 个_q 和_c 第三_m 个_q 要求_n 。_w</s><s>（_w 1_m ）_w 第二_m 个_q 要求_n 说明_v 了_u a_nx 的_u 长度_n 和_c c_nx 的_u 长度_n 是_v 相等_v 的_u ，_w 所以_c 我们_r 可以_v 列出_v 一_m 个_q 等式_n ：_w lena_nx =_w lenc_nx ；_w （_w 2_m ）_w 第三_m 个_q 要求_n 则_c 说明_v ，_w 在_p 第二_m 个_q 条件_n 成立_v 的_u 条件_n 下_f ，_w 将_p aPATc_nx 中_f 的_u A_nx 字符_n 换成_v b_nx 串_n ，_w 变为_v aPbTc_nx 。_w</s><s>如果_c 该_r 字符串_n 正确_a ，_w 那么_c aPbATac_nx 字符串_n 也_d 正确_a 。_w</s><s>仔细_ad 观察_v 不_d 难_a 发现_v ，_w P_nx 和_c A_nx 字符_n 中间_f 多_ad 加_v 了_u 一_m 个_q A_nx 字符_n ，_w 而_c 字符串_n 末尾_n c_nx 串_n 后面_f 则_c 加_v 了_u 一_m 个_q a_nx 串_n 。_w</s><s>也就是说_l ，_w c_nx 串_n 后面_f 加_v 的_u a_nx 串_n 的_u 个数_n 与_p P_nx 字符_n 和_c T_nx 字符_n 中间_f 加入_v 的_u A_nx 字符_n 的_u 个数_n 相等_v 。_w</s><s>假设_c b_nx 含有_v lenb_nx 个_q A_nx 字符_n ，_w 那么_c 新_d 加入_v 的_u A_nx 字符_n 的_u 个数_n 就_d 是_v （_w lenb_nx -_w 1_m ）_w 个_q (_w 因为_c 为了_p 保证_v 字符串_n 正确_a ，_w b_nx 中_f 最_d 起码_d 要_v 有_v 一_m 个_q A_nx 字符_n )_w 。_w</s><s>所以_c c_nx 串_v 后面_f 的_u a_nx 串_n 个数_n 也_d 就_d 是_v （_w lenb-1_nx ）_w 个_q 。_w</s><s>所以_c 可以_v 列出_v 一_m 个_q 式子_n ：_w lenc_nx =_w lenc_nx +_w （_w lenb_nx -_w 1_m ）_w *_w lena_nx 。_w</s><s>由_p 第二_m 个_q 要求_v 得出_v 的_u 式子_n lena_nx =_w lenc_nx 带入_v 得_v ：_w lenc_nx =_w lena_nx +_w （_w lenb_nx -_w 1_m ）_w *_w lena_nx 。_w</s><s>化_v 简_Ng 上_f 式_k 即_v 为_v ：_w lenc_nx =_w lena_nx *_w lenb_nx 。_w</s><s>原来_d 如此_r ~_w ~_w ~_w ~_w 拜_v 一下_m ~_w ~_w ~_w 这样_r 写_v 代码_n 就_d 简单_a 了_y #_w include_nx <_w stdio_nx ._w h_nx >_w #_nx include_nx <_w string_nx ._w h_nx >_w /_w /_w 解题_vn 关键_n (_w len_nx __w a_nx )_w P_nx (_w len_nx __w b_nx )_w T_nx (_w len_nx __w c_nx )_w /_w /_w 例_n ：_w AAPATAA_nx ,_w len_nx __w a_nx =_w 2_m ，_w len_nx __w b_nx =_w 1_m ，_w len_nx __w c_nx =_w 2_m /_w /_w 判断_vn 条件_n ：_w len_nx __w c_nx =_w len_nx __w a_nx *_w len_nx __w b_nx ，_w 并且_c len_nx __w b_nx >_w =_w 1_m 。_w</s><s>/_w /_w judge_nx ，_w 符合_v 要求_n ，_w 返回_v 1_m ，_w 否则_c 返回_v 0_m int_nx judge_nx (_w char_nx str_nx [_w ]_w )_w {_w int_nx len_nx __w a_nx ,_w len_nx __w b_nx ,_w len_nx __w c_nx ;_w /_w /_w '_w A_nx '_w 的_u 个数_n char_nx *_w p_nx ,_w *_w t_nx ;_w /_w /_w 字符串_n 中_f 有_v 非_h '_w P_nx '_w 、_w '_w A_nx '_w 、_w '_w T_nx '_w 字符_n ，_w 不_d 符合_v 要求_n for_nx (_w char_nx *_w s_nx =_w str_nx ;_w *_w s_nx !_w =_w '_w \_w 0_m '_w ;_w s_nx +_w +_w )_w {_w if_nx (_w *_w s_nx !_w =_w '_w P_nx '_w &_w &_w *_w s_nx !_w =_w '_w A_nx '_w &_w &_w *_w s_nx !_w =_w '_w T_nx '_w )_w return_v 0_m ;_w }_w /_w /_w 找出_v '_w P_nx '_w ，_w '_w T_n '_w 在_p 字符串_n 中_f 的_u 位置_n p_nx =_w strchr_nx (_w str_nx ,_w '_w P_nx '_w )_w ;_w t_nx =_w strchr_nx (_w str_nx ,_w '_w T_nx '_w )_w ;_w /_w /_w 未_d 找到_v 字符_n '_w P_nx '_w ,_w '_w T_nx '_w 或者_c '_w T_nx '_w 在_p '_w P_nx '_w 之前_f ，_w 说明_v 不_d 符合_v 要求_n if_nx (_w p_nx =_w =_w NULL_nx |_w |_w t_nx =_w =_w NULL_nx |_w |_w p_nx >_w t_nx )_w return_v 0_m ;_w /_w /_w 求_v a_nx ,_w b_nx ,_w c_nx 长度_n len_nx __w a_nx =_w p_nx -_w str_nx ;_w len_nx __w b_nx =_w t_nx -_w p_nx -_w 1_m ;_w len_nx __w c_nx =_w strlen_nx (_w t_nx +_w 1_m )_w ;_w /_w /_w 根据_p 条件_n ，_w 进行_v 判断_vn if_nx (_w len_nx __w b_nx >_w =_w 1_m &_w &_w len_nx __w c_nx =_w =_w len_nx __w a_nx *_w len_nx __w b_nx )_w return_Vg 1_m ;_w else_nx return_v 0_m ;_w }_w int_nx main_nx (_w )_w {_w int_nx n_nx ;_w char_nx str_nx [_w 10_m ]_w [_w 101_m ]_w ;_w scanf_nx (_w "_w %_m d_nx "_w ,_w &_w n_nx )_w ;_w for_v (_w int_nx i_nx =_w 0_m ;_w i_n <_w n_nx ;_w i_nx +_w +_w )_w {_w scanf_nx (_w "_w %_m s_nx "_w ,_w str_nx [_w i_m ]_w )_w ;_w if_nx (_w judge_nr (_w str_nx [_w i_m ]_w )_w =_w =_w 1_m )_w printf_nx (_w "_w YES_d \_w n_nx "_w )_w ;_w else_nx printf_nx (_w "_w NO_d \_w n_nx "_w )_w ;_w }_w return_v 0_m ;_w }_w 我_r 知道_v 是_v 啥_r 意思_n ，_w 我_r 的_u 代码_n 思路_n 和_p 你_r 的_u 一样_a ，_w 而且_c 我_r 运行_v 出来_v 的_u 结果_n 都_d 是_v 对_a 的_u 。_w</s><s>只是_d 提交_v 进_v PAT_n 测试点_n 全_d 错_v 了_y 。_w</s><s>我_r 刚_d 又_d 在_p 牛客网_n 上_f 去_v 提交_v 了_u 一_m 遍_q 发现_v 全_d 过_v 了_y ，_w 这_r 不_d 是_v 我_r 第一_m 次_q 碰到_v 这_r 种_q 情况_n 了_y 。_w</s><s>我_r 觉得_v PAT_nx 的_u 判题_vn 系统_n 可能_v 有_v BUG_n</s>
