fork download
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStream;
  4. import java.io.InputStreamReader;
  5. import java.io.PrintWriter;
  6. import java.util.ArrayList;
  7. import java.util.StringTokenizer;
  8.  
  9. public class Main {
  10.  
  11. public static void main(String[] args) throws IOException{
  12. Scanner sc = new Scanner(System.in);
  13. PrintWriter out = new PrintWriter(System.out);
  14. ArrayList<Rec> recs = new ArrayList<>();
  15. while(true)
  16. {
  17. char f = sc.nextChar();
  18. if(f == '*') break;
  19. recs.add(new Rec(new Point(sc.nextDouble(), sc.nextDouble()), new Point(sc.nextDouble(), sc.nextDouble())));
  20. }
  21. int c = 0;
  22. while(true)
  23. {
  24. double x = sc.nextDouble(), y = sc.nextDouble();
  25. if(x == 9999.9 && y == 9999.9) break;
  26. Point p = new Point(x, y);
  27. boolean found = false;
  28. c++;
  29. for(int i = 0; i < recs.size(); i++)
  30. {
  31. Rec r = recs.get(i);
  32. if(r.contains(p))
  33. {
  34. out.printf("Point %d is contained in figure %d\n", c, i+1);
  35. found = true;
  36. }
  37. }
  38. if(!found)
  39. out.printf("Point %d is not contained in any figure\n", c);
  40. }
  41. out.flush();
  42. }
  43.  
  44. static class Point
  45. {
  46. double x, y;
  47. Point(double a, double b)
  48. {
  49. x = a;
  50. y = b;
  51. }
  52. }
  53.  
  54. static class Rec
  55. {
  56. Point p1, p2;
  57. Rec(Point x, Point y)
  58. {
  59. p1 = x; p2 = y;
  60. }
  61.  
  62. boolean contains(Point p)
  63. {
  64. return p.x > p1.x && p.x < p2.x && p.y < p1.y && p.y > p2.y;
  65. }
  66. }
  67.  
  68. static class Scanner
  69. {
  70.  
  71. public Scanner(InputStream system) {br = new BufferedReader(new InputStreamReader(system));}
  72. public String next() throws IOException
  73. {
  74. while (st == null || !st.hasMoreTokens())
  75. st = new StringTokenizer(br.readLine());
  76. return st.nextToken();
  77. }
  78. public String nextLine()throws IOException{return br.readLine();}
  79. public int nextInt() throws IOException {return Integer.parseInt(next());}
  80. public double nextDouble() throws IOException {return Double.parseDouble(next());}
  81. public char nextChar()throws IOException{return next().charAt(0);}
  82. public Long nextLong()throws IOException{return Long.parseLong(next());}
  83. public boolean ready() throws IOException{return br.ready();}
  84. public void waitForInput(){for(long i = 0; i < 3e9; i++);}
  85. }
  86. }
Runtime error #stdin #stdout #stderr 0.06s 2841600KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Exception in thread "main" java.lang.NullPointerException
	at java.util.StringTokenizer.<init>(StringTokenizer.java:199)
	at java.util.StringTokenizer.<init>(StringTokenizer.java:236)
	at Main$Scanner.next(Main.java:77)
	at Main$Scanner.nextChar(Main.java:83)
	at Main.main(Main.java:17)