73 problems solved
Rank by points: #4071
Total points:
161
2 contests written
Rank by rating: #3424
Rating: 1146
Min. rating: 1146
Max rating: 1153
From University of Waterloo, Bayview S.S.
About
The difference between a master and a beginner is that the master has failed more times than the beginner has even tried.
Hi, I'm raymo
. AKA Raymond.Li. btw I use Arch.
As of Oct 1, 2021, I'm the biggest contributor to WSLg by commits. It's funny how far I've come from editing READMEs.
Awesome people from my younger days: kevinwen, asukalangley and jimgao were great mentors for me. devins taught me all of the CP I know.
Thanks to ss__jonathan and Kirito for introducing me to problem-setting.
^Adorable Dolpin!
My C++ CP template:
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
int main() {
cin.tie(0);
cin.sync_with_stdio(0);
}
Java solution template (Fast I/O, MergeSort):
import java.io.BufferedOutputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Arrays;
public class Main {
private static class FastInput {
private int s, l;
private DataInputStream d;
private byte[] b;
private int p, r;
public FastInput(int bufferSize, int inputLineLength) {
s = bufferSize;
l = inputLineLength;
d = new DataInputStream(System.in);
b = new byte[s];
p = r = 0;
}
public FastInput(int inputLineLength) {
s = 1 << 16;
l = inputLineLength;
d = new DataInputStream(System.in);
b = new byte[s];
p = r = 0;
}
public FastInput() {
s = 1 << 16;
l = 64;
d = new DataInputStream(System.in);
b = new byte[s];
p = r = 0;
}
public String getLine() throws IOException {
byte[] buf = new byte[l];
int cnt = 0, c;
while ((c = get()) != -1) {
if (c == '\n')
break;
buf[cnt++] = (byte) c;
}
return new String(buf, 0, cnt);
}
public int getInt() throws IOException {
int ret = 0;
byte c = get();
while (c <= ' ')
c = get();
boolean neg = (c == '-');
if (neg)
c = get();
do
ret = ret * 10 + c - '0';
while ((c = get()) >= '0' && c <= '9');
if (neg)
return -ret;
return ret;
}
public long getLong() throws IOException {
long ret = 0;
byte c = get();
while (c <= ' ')
c = get();
boolean neg = (c == '-');
if (neg)
c = get();
do
ret = ret * 10 + c - '0';
while ((c = get()) >= '0' && c <= '9');
if (neg)
return -ret;
return ret;
}
public double getDouble() throws IOException {
double ret = 0, div = 1;
byte c = get();
while (c <= ' ')
c = get();
boolean neg = (c == '-');
if (neg)
c = get();
do
ret = ret * 10 + c - '0';
while ((c = get()) >= '0' && c <= '9');
if (c == '.')
while ((c = get()) >= '0' && c <= '9')
ret += (c - '0') / (div *= 10);
if (neg)
return -ret;
return ret;
}
private void fillBuffer() throws IOException {
r = d.read(b, p = 0, s);
if (r == -1)
b[0] = -1;
}
private byte get() throws IOException {
if (p == r)
fillBuffer();
return b[p++];
}
public void close() throws IOException {
if (d == null)
return;
d.close();
}
}
public static void main(String[] args) throws IOException {
FastInput fi = new FastInput();
OutputStream out = new BufferedOutputStream(System.out);
fi.get();
fi.getInt();
fi.getDouble();
fi.getLine();
fi.getLine();
out.write(("" + "\n").getBytes());
fi.close();//!!!Required at end of use or code will break!!!
out.flush();//!!!Required at end of use or code will break!!!
int a[] = Arrays.stream(fi.getLine().split("\\s+")).mapToInt(Integer::parseInt).toArray(); //Get an entire line space-separated integers into an array
}
/**
* Merge sort - Faster than Arrays.sort() for primitives. int
* types can be replaced with double, long or char if you need to sort those
*
* @param a - The array that needs to be sorted
*/
private static void sort(int[] a) {
int[] tmp = new int[a.length];
mergeSort(a, tmp, 0, a.length - 1);
}
private static void mergeSort(int[] a, int[] tmp, int left, int right) {
if (left < right) {
int center = (left + right) / 2;
mergeSort(a, tmp, left, center);
mergeSort(a, tmp, center + 1, right);
merge(a, tmp, left, center + 1, right);
}
}
private static void merge(int[] a, int[] tmp, int left, int right, int rightEnd) {
int leftEnd = right - 1;
int k = left;
int num = rightEnd - left + 1;
while (left <= leftEnd && right <= rightEnd)
if (a[left] <= a[right])
tmp[k++] = a[left++];
else
tmp[k++] = a[right++];
while (left <= leftEnd) // Copy rest of first half
tmp[k++] = a[left++];
while (right <= rightEnd) // Copy rest of right half
tmp[k++] = a[right++];
for (int i = 0; i < num; i++, rightEnd--)
a[rightEnd] = tmp[rightEnd];
}
}
Rating history
, #