fork download
  1. import java.util.*;
  2.  
  3. class Interval implements Comparable<Interval> {
  4. public int start, end;
  5.  
  6. public Interval(int s, int e) {
  7. start = s;
  8. end = e;
  9. }
  10.  
  11. public boolean overlaps(Interval i) {
  12. int a = start, b = end, c = i.start, d = i.end;
  13. return ((c <= a && a <= d) || (a <= c && c <= b));
  14. }
  15.  
  16. public boolean isSame(Interval i) {
  17. return ((start == i.start) && (end == i.end));
  18. }
  19.  
  20. @Override
  21. public int compareTo(Interval i) {
  22. return end - i.end;
  23. }
  24.  
  25. @Override
  26. public String toString() {
  27. return "[start: " + start + ", end: " + end + "]";
  28. }
  29. }
  30.  
  31. public class Main {
  32. public static void main(String[] args) {
  33. // Read the input from the standard input (System.in) and print the output into the standard output (System.out)
  34. //
  35. // Everything must be implemented within this file (Main.java).
  36. // You will have to submit one file, named Main.java, to the submit server
  37.  
  38. Scanner sc = new Scanner(System.in);
  39. int i = sc.nextInt();
  40. Interval[] times = new Interval[i];
  41. int n = 0;
  42. while (n < i) {
  43. times[n++] = new Interval(sc.nextInt(),sc.nextInt());
  44. }
  45. Arrays.sort(times);
  46. HashMap<Interval,ArrayList<Interval>> res = new HashMap<Interval,ArrayList<Interval>>();
  47. ArrayList<Interval> overlap = new ArrayList<Interval>();
  48. for (n = 0; n < i; n++) {
  49. Interval a = times[n];
  50. ArrayList<Interval> noOver = new ArrayList<Interval>();
  51. for (int k = n+1; k < i; k++) {
  52. Interval b = times[k];
  53. if ((a.isSame(b) == true) || (a.overlaps(b) == true)) {
  54. continue;
  55. } else if () {
  56.  
  57. }
  58. }
  59. }
  60. }
  61. }
Compilation error #stdin compilation error #stdout 0.06s 4386816KB
stdin
5
8 10
1 5
2 7
7 9
10 12
compilation info
Main.java:55: error: illegal start of expression
        		} else if () {
        		           ^
1 error
stdout
Standard output is empty