From f333cf115a1f27043fc8ef2fadb1173100bd5146 Mon Sep 17 00:00:00 2001 From: Matej Focko Date: Sun, 23 Jul 2023 20:45:21 +0200 Subject: [PATCH] chore(java): adjust skeleton * add comments marking the regions * adjust runner to take care of SINGLE v. MULTIPLE test cases Signed-off-by: Matej Focko --- .common/java/skeleton.java | 59 +++++++++++++++++++++++++++++--------- 1 file changed, 45 insertions(+), 14 deletions(-) diff --git a/.common/java/skeleton.java b/.common/java/skeleton.java index fdad856..ceabd62 100644 --- a/.common/java/skeleton.java +++ b/.common/java/skeleton.java @@ -9,35 +9,34 @@ import java.util.Random; import java.util.StringTokenizer; public class A { - private FastScanner fs = new FastScanner(); - private PrintWriter out = new PrintWriter(System.out); - void solve() { // TODO } + // region runner + private static final boolean SINGLE = false; void run() { - solve(); + if (SINGLE) { + solve(); + } else { + int N = fs.nextInt(); + for (int i = 0; i < N; ++i) { + solve(); + } + } + out.close(); } public static void main(String[] args) { new A().run(); } + // endregion runner + // region math static final Random random = new Random(); static final int mod = 1_000_000_007; - static void ruffleSort(int[] a) { - int n = a.length;// shuffle, then sort - for (int i = 0; i < n; i++) { - int oi = random.nextInt(n), temp = a[oi]; - a[oi] = a[i]; - a[i] = temp; - } - Arrays.sort(a); - } - static long add(long a, long b) { return (a + b) % mod; } @@ -74,6 +73,18 @@ public class A { static long nCk(int n, int k) { return mul(factorials[n], mul(invFactorials[k], invFactorials[n - k])); } + // endregion math + + // region sorts + static void ruffleSort(int[] a) { + int n = a.length;// shuffle, then sort + for (int i = 0; i < n; i++) { + int oi = random.nextInt(n), temp = a[oi]; + a[oi] = a[i]; + a[i] = temp; + } + Arrays.sort(a); + } static void sort(int[] a) { ArrayList l = new ArrayList<>(); @@ -83,7 +94,25 @@ public class A { for (int i = 0; i < a.length; i++) a[i] = l.get(i); } + // endregion sorts + // region output + private PrintWriter out = new PrintWriter(System.out); + + private void yes() { + out.println("YES"); + } + + private void no() { + out.println("NO"); + } + + private void yesno(boolean ans) { + out.println(ans ? "YES" : "NO"); + } + // endregion output + + // region input static class FastScanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); @@ -113,5 +142,7 @@ public class A { return Long.parseLong(next()); } } + private FastScanner fs = new FastScanner(); + // endregion input }