Moderator: Board moderators
people[i] = new Person(parseInt(st.nextToken()),parseInt(st.nextToken()));int x = parseInt(st.nextToken());
int y = parseInt(st.nextToken());
people[i] = new Person(x, y);Darko wrote:Here is one more:
WA
- Code: Select all
people[i] = new Person(parseInt(st.nextToken()),parseInt(st.nextToken()));
AC
- Code: Select all
int x = parseInt(st.nextToken());
int y = parseInt(st.nextToken());
people[i] = new Person(x, y);
This is confusing...
st = new StringTokenizer(readLine());
String s = st.nextToken();
int val = parseInt(st.nextToken());
list.put(s, new Integer(val));
st = new StringTokenizer(readLine());
list.put(st.nextToken(), new Integer(parseInt(st.nextToken())));
Darko wrote:...and another one:
AC
- Code: Select all
st = new StringTokenizer(readLine());
String s = st.nextToken();
int val = parseInt(st.nextToken());
list.put(s, new Integer(val));
WA
- Code: Select all
st = new StringTokenizer(readLine());
list.put(st.nextToken(), new Integer(parseInt(st.nextToken())));
It's not even a case of multiple dereferencing, I have no idea why the latter one fails.
import java.io.IOException;
class MainReadAll {
int inputIndex;
int inputSize;
byte[] input;
void work() {
readAll(65536); // pick estimated size of input - powers of two work the
// best
int n;
while((n=nextInt())!= Integer.MIN_VALUE){
// do stuff
}
}
private void readAll(int bufSize) {
input = new byte[bufSize];
int start = 0;
inputSize = 0;
while (true) {
try {
int read = System.in.read(input, start, 2048);
inputSize += read;
if (read < 2048)
break;
start += 2048;
} catch (IOException e) {
}
}
inputIndex = 0;
}
private int nextInt() {
// find first digit
while (input[inputIndex] < '-') {
if (inputIndex == inputSize)
return Integer.MIN_VALUE;
inputIndex++;
}
int k = 0;
int sign = 1;
if (input[inputIndex] == '-') {
inputIndex++;
sign = -1;
} else
k = input[inputIndex++] - 48;
// read the number
while (input[inputIndex] >= '0' && input[inputIndex] <= '9') {
k *= 10;
k += (input[inputIndex++] - 48);
}
return k * sign;
}
public static void main(String args[]) {
MainReadAll myWork = new MainReadAll();
myWork.work();
}
}
Users browsing this forum: No registered users and 1 guest