From 13fa5d531fc943388aa43a77830a3fee90db120d Mon Sep 17 00:00:00 2001 From: nchn27 <46332369+nchn27@users.noreply.github.com> Date: Sat, 4 Jul 2020 00:34:29 -0400 Subject: [PATCH] Update IO_Speed.mdx --- content/2_General/IO_Speed.mdx | 40 +++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/content/2_General/IO_Speed.mdx b/content/2_General/IO_Speed.mdx index dd54062..8713468 100644 --- a/content/2_General/IO_Speed.mdx +++ b/content/2_General/IO_Speed.mdx @@ -1,7 +1,7 @@ --- id: io-speed title: Input / Output Speed -author: Benjamin Qi +author: Benjamin Qi / Nathan Chen description: "" --- @@ -116,14 +116,42 @@ int main() { ### Java -(scanner?) +The Java `Scanner` is probably the easiest way to read input in Java, though it is also extremely slow. -(buffered reader?) + + +```java +import java.util.*; +import java.io.*; + +public class roboherd_scanner { + + static int P[][] = new int[100000][]; + + public static void main(String[] args) throws Exception { + Scanner sc = new Scanner(new File("roboherd.in")); + PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter("roboherd.out"))); + + int N = sc.nextInt(); + int K = sc.nextInt(); + for(int i = 0; i < N; ++i) { + int M = sc.nextInt(); P[i] = new int[M]; + for(int j = 0; j < M; ++j) P[i][j] = sc.nextInt(); + } + + if(N == 3) pw.println(61); + else pw.println(1000000000000000000L); + pw.close(); + } +} +``` + + + +A combination of (custom I/O?) -(streamtokenizer instead of stringtokenizer? see http://www.usaco.org/current/data/sol_threesum_gold_jan20.html) - ### Python Faster than the first C++ method! Significantly less if $P$ does not need to be stored. @@ -150,4 +178,4 @@ else: (not using endl?) -(printing out one thing at end?) \ No newline at end of file +(printing out one thing at end?)