FastIO - #3 - Competitive Programming In Java

preview_player
Показать описание
Fast input and output can be decisive in a contest. Here is how we do it in java.
Рекомендации по теме
Комментарии
Автор

Hi! I didn't quite understand the following:
private InputStream stream;
private byte[] buf = new byte[1024];

private int curChar;

private int numChars;

public InputReader(InputStream stream) {
this.stream = stream; //1
}

public int read() {
if (numChars == -1)
throw new RuntimeException();
if (curChar >= numChars) {
curChar = 0;
try {
numChars = stream.read(buf);
} catch (IOException e) {
throw new RuntimeException();
}
if (numChars <= 0)
return -1;
}
return buf[curChar++];
}
1.Did you equate the InputStream stream null reference to -System.in- in main method when u construct the FastIO object? If yes, what happens by this? Was this done to invoke the Inputstream.read(buf)?
The oracle documentation states that InputStream is an abstract class so can we call its methods without any object instantiation?(i didn't quite understand how you called stream.read(buf) using the reference variable

What is the use of buf array?

isaacsanctis
Автор

Hey..This approach for reading String is not reading strings which have any whitespace is between. Ex "gau rav", output is coming as "gau", but expected output should be "gau rav".

gibranmohammadkhan
Автор

IntelliJ most probably builds everytime we type in something. It mostly becomes unresponsive while in the middle of a contest. I prefer to use text editor like Sublime Test instead. Is it good or bad?? I am comfortable with it.

mynameisisu
Автор

seems that you are a bengali. Tahole... kothay thaken? Ar video kotha theke hochchhe... nischoyi kono main road??
video is good

debanjandey
Автор

Tnx bro.Now I am able get all my partially accepted solutions to accepted which required fast Io.

tarunreddy
Автор

After using that input class template, I'm getting RunTimeException. Though it is working in my compiler and custom inputs in Codechef when I'm running it or submitting, it is giving me this exception. Pls help

harshvardhanthakur
Автор

Hey @Gaurav do you recommend this Fast IO approach for programming interviews as well? As I think that it would be difficult to remember this approach for programming interviews. If not Fast IO, then which would be better between bufferedreader and scanner?

DeepanshuGabba
Автор

I have a doubt in readInt() function, u did defined character as a type of "int" and compared it with the character 0 and 9 in if condition, can u explain, please?

surajsuryawanshi
Автор

Hey, is this Fast Input class faster than Scanner?

shreyanshmurarka
Автор

Hi, dont you think that expansion of Stringbuffer could be more costly?

rahuldeepattri
Автор

It has been 5 years. You must have replaced the keyboard especially due to the enter key xD

charan
Автор

Every time you press the Enter Key, I feel sorry for your keyboard.

v.subramaniraju
Автор

how are you going to perform "taking input from a file" with the help of this code ?

shahriarmim
welcome to shbcf.ru