Skip to content

Commit 2bc6a1f

Browse files
wkoderMoises Osorio
authored andcommitted
Fix some issues and delete bad code.
1 parent bc286ba commit 2bc6a1f

File tree

9 files changed

+302
-20
lines changed

9 files changed

+302
-20
lines changed

.DS_Store

6 KB
Binary file not shown.

.idea/algorithms.iml

Lines changed: 9 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/Project_Default.xml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/libraries/gson_2_8_2.xml

Lines changed: 0 additions & 9 deletions
This file was deleted.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/uiDesigner.xml

Lines changed: 124 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scratch/Main.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
import java.io.IOException;
33
import java.io.InputStream;
44
import java.io.PrintWriter;
5-
import java.util.InputMismatchException;
5+
import java.util.*;
6+
import java.util.stream.Collectors;
7+
import java.util.stream.Stream;
68

79
public class Main implements Runnable {
8-
private void solve() {
9-
10+
private static void solve() {
11+
1012
}
1113

1214
/** Template starts: */
@@ -117,10 +119,6 @@ long readLong() {
117119
return res * sgn;
118120
}
119121

120-
double readDouble() {
121-
return Double.parseDouble(readString());
122-
}
123-
124122
String readString() {
125123
byte c = read();
126124
while (isWhitespace(c)) {

scratch/Solution.java

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
import java.io.BufferedOutputStream;
2+
import java.io.IOException;
3+
import java.io.InputStream;
4+
import java.io.PrintWriter;
5+
import java.util.*;
6+
7+
public class Solution implements Runnable {
8+
private void solve() {
9+
10+
}
11+
12+
/** Template starts: */
13+
@Override
14+
public void run() {
15+
solve();
16+
out.flush();
17+
System.exit(0);
18+
}
19+
20+
private final static InputReader in = new InputReader(System.in);
21+
private final static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
22+
23+
public static void main(String[] args) {
24+
new Thread(null, new Solution(), "Main", 1 << 26).start();
25+
}
26+
27+
private static class InputReader {
28+
private final InputStream stream;
29+
private final byte[] buf = new byte[1024];
30+
private int curChar;
31+
private int numChars;
32+
33+
InputReader(InputStream stream) {
34+
this.stream = stream;
35+
}
36+
37+
private byte read() {
38+
if (numChars == -1) {
39+
throw new InputMismatchException("EOF has been reached");
40+
}
41+
if (curChar >= numChars) {
42+
curChar = 0;
43+
try {
44+
numChars = stream.read(buf);
45+
} catch (IOException e) {
46+
throw new InputMismatchException();
47+
}
48+
if (numChars <= 0)
49+
return -1;
50+
}
51+
return buf[curChar++];
52+
}
53+
54+
int readInt() {
55+
byte c = read();
56+
while (isWhitespace(c)) {
57+
c = read();
58+
}
59+
if (isEOF(c)) {
60+
throw new InputMismatchException("EOF has been reached");
61+
}
62+
63+
int sgn = 1;
64+
if (c == '-') {
65+
sgn = -1;
66+
c = read();
67+
}
68+
int res = 0;
69+
do {
70+
if (c < '0' || c > '9') {
71+
throw new InputMismatchException();
72+
}
73+
if (res > Integer.MAX_VALUE / 10) {
74+
throw new InputMismatchException("Input is not an integer");
75+
}
76+
res *= 10;
77+
int d = c - '0';
78+
if (res > Integer.MAX_VALUE - d) {
79+
throw new InputMismatchException("Input is not an integer");
80+
}
81+
res += d;
82+
c = read();
83+
} while (!isWhitespaceOrEOF(c));
84+
return res * sgn;
85+
}
86+
87+
long readLong() {
88+
byte c = read();
89+
while (isWhitespace(c)) {
90+
c = read();
91+
}
92+
if (isEOF(c)) {
93+
throw new InputMismatchException("EOF has been reached");
94+
}
95+
96+
int sgn = 1;
97+
if (c == '-') {
98+
sgn = -1;
99+
c = read();
100+
}
101+
long res = 0;
102+
do {
103+
if (c < '0' || c > '9') {
104+
throw new InputMismatchException();
105+
}
106+
if (res > Long.MAX_VALUE / 10) {
107+
throw new InputMismatchException("Input is not a long integer");
108+
}
109+
res *= 10;
110+
int d = c - '0';
111+
if (res > Long.MAX_VALUE - d) {
112+
throw new InputMismatchException("Input is not a long integer");
113+
}
114+
res += d;
115+
c = read();
116+
} while (!isWhitespaceOrEOF(c));
117+
return res * sgn;
118+
}
119+
120+
double readDouble() {
121+
return Double.parseDouble(readString());
122+
}
123+
124+
String readString() {
125+
byte c = read();
126+
while (isWhitespace(c)) {
127+
c = read();
128+
}
129+
if (isEOF(c)) {
130+
return null;
131+
}
132+
133+
StringBuilder res = new StringBuilder();
134+
do {
135+
if (Character.isValidCodePoint(c)) {
136+
res.appendCodePoint(c);
137+
}
138+
c = read();
139+
} while (!isWhitespaceOrEOF(c));
140+
return res.toString();
141+
}
142+
143+
private boolean isWhitespace(byte c) {
144+
return c == ' ' || c == '\n' || c == '\r' || c == '\t';
145+
}
146+
147+
private boolean isEOF(byte c) {
148+
return c == -1;
149+
}
150+
151+
private boolean isWhitespaceOrEOF(byte c) {
152+
return isWhitespace(c) || isEOF(c);
153+
}
154+
}
155+
}

templates/ScannerTemplate.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import java.io.BufferedOutputStream;
22
import java.io.InputStreamReader;
33
import java.io.PrintWriter;
4+
import java.util.Arrays;
45
import java.util.Scanner;
56

67
public class ScannerTemplate implements Runnable {

0 commit comments

Comments
 (0)