Created
          March 13, 2018 16:18 
        
      - 
      
- 
        Save kevin51jiang/a192c6a6fff06fa3e22cfe798ab85300 to your computer and use it in GitHub Desktop. 
    Some CP thing
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import java.io.BufferedReader; | |
| import java.io.IOException; | |
| import java.io.InputStreamReader; | |
| import java.util.ArrayList; | |
| /** | |
| * You know what's better than a bucket that wraps an arraylist? | |
| * | |
| * A BucketBucket which wraps an array of buckets which each wraps an ArrayList. | |
| * @author Kevin Jiang | |
| */ | |
| public class CCC00J1 { | |
| static class BucketBucket{ | |
| Bucket[] bucks; | |
| public BucketBucket (int numLen){ | |
| bucks = new Bucket[numLen + 1]; | |
| } | |
| public void add(String str){ | |
| bucks[str.length()].add(str); | |
| } | |
| public boolean contains(String str){ | |
| return bucks[str.length()].isContain(str); | |
| } | |
| static class Bucket{ | |
| ArrayList<String> list = new ArrayList<>(); | |
| public Bucket(){} | |
| public void add(String str){ | |
| list.add(str); | |
| } | |
| public boolean isContain(String query){ | |
| return list.contains(query); | |
| } | |
| } | |
| } | |
| static BucketBucket buckets; | |
| public static void main(String[] args) throws IOException { | |
| BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); | |
| final int n = Integer.parseInt(reader.readLine()); | |
| buckets = new BucketBucket(n); | |
| for (int i = 0; i < n; i++) { | |
| buckets.add(reader.readLine()); | |
| } | |
| for (int i = 0; i < 10; i++) { | |
| System.out.println(solve(reader.readLine(), 0)); | |
| } | |
| } | |
| /** | |
| * Idk some recursive stuff. | |
| * Random brute force? | |
| * @param str | |
| */ | |
| private static int solve(String str, int end) { | |
| if(str.isEmpty()){ | |
| return 0; | |
| }else{ | |
| if(buckets.contains(str.substring(0, end))){ | |
| return 1; | |
| }else{ | |
| } | |
| } | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
NOT FINISHED.