Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.HashMap;
- import java.util.Scanner;
- public class Speluvanje {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- HashMap<String,String> map = new HashMap<String,String>();
- String n = sc.nextLine();
- for(int i =0;i<Integer.parseInt(n);i++)
- {
- String s = sc.nextLine();
- map.put(s, s);
- }
- String x = "";
- int los = 0;
- boolean kluc = true;
- while(sc.hasNext())
- {
- kluc = true;
- String a = sc.next();
- char z = a.charAt(0);
- if(!Character.isLetter(z))
- {
- System.out.println("Bravo");
- return;
- }
- if(!map.containsKey(a))
- {
- if(map.containsKey(a.toLowerCase()))
- {
- kluc = false;
- }
- if(map.containsKey(a.substring(0, a.length()-1)))
- {
- kluc = false;
- }
- if(map.containsKey(a.toLowerCase().substring(0, a.length()-1)))
- {
- kluc = false;
- }
- if(kluc == true)
- {
- los++;
- if(!Character.isLetter(a.charAt(a.length()-1)))
- x += "\n" + a.substring(0 , a.length()-1);
- else
- x += "\n" + a;
- }
- }
- }
- if(los == 0)
- {
- System.out.println("Bravo");
- }
- else
- {
- System.out.println(x);
- }
- sc.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement