Trang

Thứ Hai, 3 tháng 1, 2011

3472. Chopin

import java.io.*;

public class Main {

    /**
     * http://acm.tju.edu.cn/toj/showp3472.html
     * @author hunglee
     */
    public static void main(String[] args) throws IOException {
        
        BufferedReader in = new BufferedReader(
                new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        
        int t = Integer.parseInt(in.readLine());
        String[] s;
        while (t-- > 0) {
            s = in.readLine().split(" ");
            if (valid(s))
                out.println("yes");
            else
                out.println("no");
        }
        out.flush();
    }

    private static boolean valid(String[] s) {

        int i = 0, j = 0;
        while (i < s[0].length() && j < s[1].length())
            if (s[0].charAt(i) == s[1].charAt(j)) {
                ++i; ++j;
            } else
                ++i;
        return (j == s[1].length());
    }

}

Không có nhận xét nào:

Đăng nhận xét