Submission #172260

#TimeUsernameProblemLanguageResultExecution timeMemory
172260ijxjdjdArranging Shoes (IOI19_shoes)Java
Compilation error
0 ms0 KiB
public class shoes { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); shoe solver = new shoe(); solver.solve(1, in, out); out.close(); } static class shoe { public void solve(int testNumber, InputReader in, PrintWriter out) { int N = in.nextInt(); ArrayDeque<Integer>[] left = new ArrayDeque[N]; ArrayDeque<Integer>[] right = new ArrayDeque[N]; for (int i = 0; i < N; i++) { left[i] = new ArrayDeque<>(); right[i] = new ArrayDeque<>(); } FenwickTree unset = new FenwickTree(2 * N); for (int i = 0; i < 2 * N; i++) { int a = in.nextInt(); if (a < 0) { left[(-a) - 1].add(i); } else { right[a - 1].add(i); } unset.add(i, 1); } long res = 0; PriorityQueue<int[]> next = new PriorityQueue<>(new Comparator<int[]>() { public int compare(int[] ints, int[] t1) { return Integer.compare(ints[0] + ints[1] + (ints[0] > ints[1] ? 1 : 0), t1[0] + t1[1] + (t1[0] > t1[1] ? 1 : 0)); } }); for (int i = 0; i < N; i++) { if (left[i].size() > 0) { next.add(new int[]{left[i].remove(), right[i].remove(), i}); } } for (int i = 0; i < N; i++) { int[] a = next.remove(); res += (unset.sum(a[0]) - 1); unset.add(a[0], -1); res += (unset.sum(a[1]) - 1); unset.add(a[1], -1); if (left[a[2]].size() > 0) { next.add(new int[]{left[a[2]].remove(), right[a[2]].remove(), a[2]}); } } out.println(res); } } static class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream), 32768); tokenizer = null; } public String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } public int nextInt() { return Integer.parseInt(next()); } } static class FenwickTree { public int[] BIT; public int size = 0; public FenwickTree(int N) { BIT = new int[N]; size = N; } public FenwickTree(int[] arr) { size = arr.length; BIT = new int[arr.length]; for (int i = 0; i < size; i++) { add(i, arr[i]); } } public void add(int id, int add) { for (int i = id; i < size; i |= i + 1) { BIT[i] += add; } } public int sum(int r) { if (r < 0 || r >= size) { return 0; } int res = 0; for (int i = r; i >= 0; i = ((i) & (i + 1)) - 1) { res += BIT[i]; } return res; } } }

Compilation message (stderr)

shoes.java:13: error: cannot find symbol
        public void solve(int testNumber, InputReader in, PrintWriter out) {
                                                          ^
  symbol:   class PrintWriter
  location: class shoe
shoes.java:59: error: cannot find symbol
        public BufferedReader reader;
               ^
  symbol:   class BufferedReader
  location: class InputReader
shoes.java:60: error: cannot find symbol
        public StringTokenizer tokenizer;
               ^
  symbol:   class StringTokenizer
  location: class InputReader
shoes.java:62: error: cannot find symbol
        public InputReader(InputStream stream) {
                           ^
  symbol:   class InputStream
  location: class InputReader
shoes.java:3: error: cannot find symbol
        InputStream inputStream = System.in;
        ^
  symbol:   class InputStream
  location: class shoes
shoes.java:4: error: cannot find symbol
        OutputStream outputStream = System.out;
        ^
  symbol:   class OutputStream
  location: class shoes
shoes.java:6: error: cannot find symbol
        PrintWriter out = new PrintWriter(outputStream);
        ^
  symbol:   class PrintWriter
  location: class shoes
shoes.java:6: error: cannot find symbol
        PrintWriter out = new PrintWriter(outputStream);
                              ^
  symbol:   class PrintWriter
  location: class shoes
shoes.java:15: error: cannot find symbol
            ArrayDeque<Integer>[] left = new ArrayDeque[N];
            ^
  symbol:   class ArrayDeque
  location: class shoe
shoes.java:15: error: cannot find symbol
            ArrayDeque<Integer>[] left = new ArrayDeque[N];
                                             ^
  symbol:   class ArrayDeque
  location: class shoe
shoes.java:16: error: cannot find symbol
            ArrayDeque<Integer>[] right = new ArrayDeque[N];
            ^
  symbol:   class ArrayDeque
  location: class shoe
shoes.java:16: error: cannot find symbol
            ArrayDeque<Integer>[] right = new ArrayDeque[N];
                                              ^
  symbol:   class ArrayDeque
  location: class shoe
shoes.java:18: error: cannot find symbol
                left[i] = new ArrayDeque<>();
                              ^
  symbol:   class ArrayDeque
  location: class shoe
shoes.java:19: error: cannot find symbol
                right[i] = new ArrayDeque<>();
                               ^
  symbol:   class ArrayDeque
  location: class shoe
shoes.java:32: error: cannot find symbol
            PriorityQueue<int[]> next = new PriorityQueue<>(new Comparator<int[]>() {
            ^
  symbol:   class PriorityQueue
  location: class shoe
shoes.java:32: error: cannot find symbol
            PriorityQueue<int[]> next = new PriorityQueue<>(new Comparator<int[]>() {
                                            ^
  symbol:   class PriorityQueue
  location: class shoe
shoes.java:32: error: cannot find symbol
            PriorityQueue<int[]> next = new PriorityQueue<>(new Comparator<int[]>() {
                                                                ^
  symbol:   class Comparator
  location: class shoe
shoes.java:63: error: cannot find symbol
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
                         ^
  symbol:   class BufferedReader
  location: class InputReader
shoes.java:63: error: cannot find symbol
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
                                            ^
  symbol:   class InputStreamReader
  location: class InputReader
shoes.java:70: error: cannot find symbol
                    tokenizer = new StringTokenizer(reader.readLine());
                                    ^
  symbol:   class StringTokenizer
  location: class InputReader
shoes.java:71: error: cannot find symbol
                } catch (IOException e) {
                         ^
  symbol:   class IOException
  location: class InputReader
grader.java:23: error: cannot find symbol
		long result = solver.count_swaps(S);
		                    ^
  symbol:   method count_swaps(int[])
  location: variable solver of type shoes
22 errors