import java.io.*; import java.util.*; /** * First, identify how long the shortest missing subsequences will be. * Do this by iterating over the string, and waiting for all characters to * appear before resetting the appeared characters and incrementing a counter. * * Preprocess the input by the index of the next (or current) occurence of each character. * For each query string, test if it is a subsequence by finding the smallest index * of an occurence of the next character in the query string greater than the current * index in the given reference string. * @author Finn Lidbetter */ public class sms_scanner_io { public static void main(String[] args) { Scanner sc = new Scanner(System.in); char[] chAlphabet = sc.nextLine().toCharArray(); HashSet alphabetSet = new HashSet<>(); for (char ch: chAlphabet) { alphabetSet.add(ch); } char[] seq = sc.nextLine().toCharArray(); int[][] table = new int[26][seq.length]; for (int c=0; c<26; c++) { int prev = -2; for (int i=seq.length-1; i>=0; i--) { if (seq[i]==(char)((int)'a'+c)) { prev = i; } table[c][i] = prev; } } int targetLength = 1; HashSet seen = new HashSet<>(); for (int i=0; i(); targetLength++; } } int n = Integer.parseInt(sc.nextLine()); for (int i=0; i= seq.length) { isSubsequence = false; break; } currIndex = table[ch-'a'][currIndex] + 1; } if (currIndex==-1) { isSubsequence = false; } if (isSubsequence) { System.out.println("0"); } else { System.out.println("1"); } } } }