Submission #725956

# Submission time Handle Problem Language Result Execution time Memory
725956 2023-04-18T09:21:48 Z browntoad Exhibition (JOI19_ho_t2) C++14
Compilation error
0 ms 0 KB
import java.util.*
 
class FastIO extends PrintWriter {
	private InputStream stream;
	private byte[] buf = new byte[1 << 16];
	private int curChar;
	private int numChars;

	// standard input
	public FastIO() { this(System.in, System.out); }

	public FastIO(InputStream i, OutputStream o) {
		super(o);
		stream = i;
	}

	// file input
	public FastIO(String i, String o) throws IOException {
		super(new FileWriter(o));
		stream = new FileInputStream(i);
	}

	// throws InputMismatchException() if previously detected end of file
	private int nextByte() {
		if (numChars == -1) { throw new InputMismatchException(); }
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) { throw new InputMismatchException(); }
			if (numChars == -1) {
				return -1;  // end of file
			}
		}
		return buf[curChar++];
	}

	// to read in entire lines, replace c <= ' '
	// with a function that checks whether c is a line break
	public String next() {
		int c;
		do { c = nextByte(); } while (c <= ' ');

		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = nextByte();
		} while (c > ' ');
		return res.toString();
	}

	public int nextInt() {  // nextLong() would be implemented similarly
		int c;
		do { c = nextByte(); } while (c <= ' ');

		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = nextByte();
		}

		int res = 0;
		do {
			if (c < '0' || c > '9') { throw new InputMismatchException(); }
			res = 10 * res + c - '0';
			c = nextByte();
		} while (c > ' ');
		return res * sgn;
	}

	public double nextDouble() { return Double.parseDouble(next()); }
}
class Pair {
    int x;
    int y;
 
    // Constructor
    public Pair(int x, int y) {
        this.x = x;
        this.y = y;
    }
}
 
class ArrayOfPairsSorter {
 
    static void sort(Pair[] arr) {
        Comparator<Pair> comparator = new Comparator<>() {
            @Override
            public int compare(Pair p1, Pair p2) {
                if (p1.y == p2.y) return p1.x - p2.x; 
                return p1.y - p2.y;
            }
        };
        Arrays.sort(arr, comparator);
    }
}
 
 
class joi2019_ho_t2 {
    public static void main(String[] args){
        FastIO io = new FastIO();
        int N = io.nextInt();
        int M = io.nextInt();
 
        Pair[] pictures = new Pair[N];
        ArrayList<Integer> frame = new ArrayList<Integer>();
 
        for (int i=0; i<N; i++) {
            pictures[i] = new Pair(io.nextInt(), io.nextInt());
        }
 
        for (int i=0; i<M; i++) {
            frame.add(io.nextInt());
        }
 
        ArrayOfPairsSorter.sort(pictures);
 
        Collections.sort(frame);
int paintingCounter = N;
 
        int frameCounter = M-1;
        for (int i=N-1; i>=0; i--) {
            if (frameCounter >= 0) {
                if (pictures[i].x <= frame.get(frameCounter)) {
                    frameCounter -= 1;
                }
            }
        }
        System.out.println(M - 1 - frameCounter);
    }
}

Compilation message

joi2019_ho_t2.cpp:88:13: error: stray '@' in program
   88 |             @Override
      |             ^
joi2019_ho_t2.cpp:1:1: error: 'import' does not name a type
    1 | import java.util.*
      | ^~~~~~
joi2019_ho_t2.cpp:78:11: error: expected ':' before 'Pair'
   78 |     public Pair(int x, int y) {
      |           ^~~~~
      |           :
joi2019_ho_t2.cpp:82:2: error: expected ';' after class definition
   82 | }
      |  ^
      |  ;
joi2019_ho_t2.cpp: In constructor 'Pair::Pair(int, int)':
joi2019_ho_t2.cpp:79:14: error: request for member 'x' in '(Pair*)this', which is of pointer type 'Pair*' (maybe you meant to use '->' ?)
   79 |         this.x = x;
      |              ^
joi2019_ho_t2.cpp:80:14: error: request for member 'y' in '(Pair*)this', which is of pointer type 'Pair*' (maybe you meant to use '->' ?)
   80 |         this.y = y;
      |              ^
joi2019_ho_t2.cpp: At global scope:
joi2019_ho_t2.cpp:86:29: error: expected ',' or '...' before 'arr'
   86 |     static void sort(Pair[] arr) {
      |                             ^~~
joi2019_ho_t2.cpp:96:2: error: expected ';' after class definition
   96 | }
      |  ^
      |  ;
joi2019_ho_t2.cpp: In static member function 'static void ArrayOfPairsSorter::sort(Pair*)':
joi2019_ho_t2.cpp:87:9: error: 'Comparator' was not declared in this scope
   87 |         Comparator<Pair> comparator = new Comparator<>() {
      |         ^~~~~~~~~~
joi2019_ho_t2.cpp:87:24: error: expected primary-expression before '>' token
   87 |         Comparator<Pair> comparator = new Comparator<>() {
      |                        ^
joi2019_ho_t2.cpp:87:26: error: 'comparator' was not declared in this scope
   87 |         Comparator<Pair> comparator = new Comparator<>() {
      |                          ^~~~~~~~~~
joi2019_ho_t2.cpp:87:43: error: 'Comparator' does not name a type
   87 |         Comparator<Pair> comparator = new Comparator<>() {
      |                                           ^~~~~~~~~~
joi2019_ho_t2.cpp:87:54: error: expected primary-expression before '>' token
   87 |         Comparator<Pair> comparator = new Comparator<>() {
      |                                                      ^
joi2019_ho_t2.cpp:87:56: error: expected primary-expression before ')' token
   87 |         Comparator<Pair> comparator = new Comparator<>() {
      |                                                        ^
joi2019_ho_t2.cpp:94:9: error: 'Arrays' was not declared in this scope
   94 |         Arrays.sort(arr, comparator);
      |         ^~~~~~
joi2019_ho_t2.cpp:94:21: error: 'arr' was not declared in this scope
   94 |         Arrays.sort(arr, comparator);
      |                     ^~~
joi2019_ho_t2.cpp: At global scope:
joi2019_ho_t2.cpp:100:11: error: expected ':' before 'static'
  100 |     public static void main(String[] args){
      |           ^~~~~~~
      |           :
joi2019_ho_t2.cpp:100:29: error: 'String' has not been declared
  100 |     public static void main(String[] args){
      |                             ^~~~~~
joi2019_ho_t2.cpp:100:38: error: expected ',' or '...' before 'args'
  100 |     public static void main(String[] args){
      |                                      ^~~~
joi2019_ho_t2.cpp:131:2: error: expected ';' after class definition
  131 | }
      |  ^
      |  ;
joi2019_ho_t2.cpp: In static member function 'static void joi2019_ho_t2::main(int*)':
joi2019_ho_t2.cpp:101:9: error: 'FastIO' was not declared in this scope
  101 |         FastIO io = new FastIO();
      |         ^~~~~~
joi2019_ho_t2.cpp:102:17: error: 'io' was not declared in this scope
  102 |         int N = io.nextInt();
      |                 ^~
joi2019_ho_t2.cpp:105:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
  105 |         Pair[] pictures = new Pair[N];
      |             ^
joi2019_ho_t2.cpp:105:13: error: structured binding declaration cannot have type 'Pair'
  105 |         Pair[] pictures = new Pair[N];
      |             ^~
joi2019_ho_t2.cpp:105:13: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
joi2019_ho_t2.cpp:105:13: error: empty structured binding declaration
joi2019_ho_t2.cpp:105:16: error: expected initializer before 'pictures'
  105 |         Pair[] pictures = new Pair[N];
      |                ^~~~~~~~
joi2019_ho_t2.cpp:106:9: error: 'ArrayList' was not declared in this scope
  106 |         ArrayList<Integer> frame = new ArrayList<Integer>();
      |         ^~~~~~~~~
joi2019_ho_t2.cpp:106:19: error: 'Integer' was not declared in this scope
  106 |         ArrayList<Integer> frame = new ArrayList<Integer>();
      |                   ^~~~~~~
joi2019_ho_t2.cpp:106:28: error: 'frame' was not declared in this scope
  106 |         ArrayList<Integer> frame = new ArrayList<Integer>();
      |                            ^~~~~
joi2019_ho_t2.cpp:106:40: error: 'ArrayList' does not name a type
  106 |         ArrayList<Integer> frame = new ArrayList<Integer>();
      |                                        ^~~~~~~~~
joi2019_ho_t2.cpp:106:59: error: expected primary-expression before ')' token
  106 |         ArrayList<Integer> frame = new ArrayList<Integer>();
      |                                                           ^
joi2019_ho_t2.cpp:109:13: error: 'pictures' was not declared in this scope
  109 |             pictures[i] = new Pair(io.nextInt(), io.nextInt());
      |             ^~~~~~~~
joi2019_ho_t2.cpp:116:27: error: expected unqualified-id before '.' token
  116 |         ArrayOfPairsSorter.sort(pictures);
      |                           ^
joi2019_ho_t2.cpp:118:9: error: 'Collections' was not declared in this scope
  118 |         Collections.sort(frame);
      |         ^~~~~~~~~~~
joi2019_ho_t2.cpp:124:21: error: 'pictures' was not declared in this scope
  124 |                 if (pictures[i].x <= frame.get(frameCounter)) {
      |                     ^~~~~~~~
joi2019_ho_t2.cpp:129:9: error: 'System' was not declared in this scope
  129 |         System.out.println(M - 1 - frameCounter);
      |         ^~~~~~
joi2019_ho_t2.cpp:105:13: warning: unused structured binding declaration [-Wunused-variable]
  105 |         Pair[] pictures = new Pair[N];
      |             ^~
joi2019_ho_t2.cpp:119:5: warning: unused variable 'paintingCounter' [-Wunused-variable]
  119 | int paintingCounter = N;
      |     ^~~~~~~~~~~~~~~