diff --git a/README.md b/README.md index 526e9b1..11cc11e 100644 --- a/README.md +++ b/README.md @@ -1 +1,5 @@ -# Java \ No newline at end of file +# Java +Useful library for usaco and other purposes. +. Use releases when possible otherwise download usacotools.java. +# Release dates and more +Find release dates at https://javaarchive.github.io/Java/. Moved to https://github.com/javaarchive/Java/wiki diff --git a/_config.yml b/_config.yml new file mode 100644 index 0000000..c419263 --- /dev/null +++ b/_config.yml @@ -0,0 +1 @@ +theme: jekyll-theme-cayman \ No newline at end of file diff --git a/compilestandard.java b/compilestandard.java new file mode 100644 index 0000000..1b31cf1 --- /dev/null +++ b/compilestandard.java @@ -0,0 +1,57 @@ +import java.io.*; +import java.security.MessageDigest; +import java.security.*; +public class compilestandard extends usacotools { + public static String sha256(String input) throws NoSuchAlgorithmException { + MessageDigest mDigest = MessageDigest.getInstance("SHA-256"); + byte[] result = mDigest.digest(input.getBytes()); + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < result.length; i++) { + sb.append(Integer.toString((result[i] & 0xff) + 0x100, 16).substring(1)); + } + + return sb.toString(); + } + public static void main(String[] args) throws IOException{ + // TODO Auto-generated method stub + BufferedReader f; + if(args.length==1) { + if(args[0].equals("eclipse")) { + f=mreader("src/usacotools.java"); + }else { + f=mreader("usacotools.java"); + } + + }else { + f=mreader("usacotools.java"); + } + + print("build"); + + String st; + String full=""; + + while ((st = f.readLine()) != null) { + full=full+st+"\n"; + } + String text=full.replace("if(!(lock)) {return null;}", ""); + text=text.replace("public abstract class usacotools","public abstract class utools"); + print(text); + PrintWriter pw=mwriter("utools.java"); + if(args[0].equals("eclipse")) { + pw=mwriter("src/utools.java"); + }else { + + } + pw.println(text); + pw.close(); + print("utools.java is the one you should copy into your code but usacotools is the one you should extend"); + try{ + print("utools.java SHA256: "+sha256(text)); + print("usacotools.java SHA256: "+sha256(full)); + }catch(Exception e) { + e.printStackTrace(); + } + + } +} diff --git a/debuggableapp.java b/debuggableapp.java new file mode 100644 index 0000000..1431b80 --- /dev/null +++ b/debuggableapp.java @@ -0,0 +1,70 @@ +import java.io.*; +import java.util.*; +class Var { + private Object object; + public Var() { + this.object=null; + } + public Var(Object o) { + this.object=o; + } + public void set(Object object) { this.object = object; } + public Object get() { return object; } +} +public class debuggableapp { + public static PrintWriter debug; + public static HashMap db=new HashMap(); + public static void setup() { + try { + debug=new PrintWriter(new BufferedWriter(new FileWriter("programdebug.info"))); + }catch(Exception e) { + e.printStackTrace(); + System.out.println("WARNING:Log file cannot be initliazed, redirecting to stdout! This may be a restrcited system!"); + debug=new PrintWriter(System.out); + + } + debug.println("Setup completed"); + } + public static void session() { + debug.println("Session started"); + System.out.println("Debug 1.0 Session\nPress enter to stop\nWarning timing this program will be messed up!"); + String text=">"; + Scanner sc=new Scanner(System.in); + while(!(text.equals(""))) { + System.out.print(">"); + text=sc.nextLine(); + if(db.containsKey(text)) { + show(db.get(text)); + } + } + } + public static void show(Var x) { + debug.println(x.getClass()); + if(x.getClass().getName().contains((CharSequence) "List")) { + System.out.println("WARNING this is a list"); + debug.println("WARNING this is a list"); + } + System.out.println(x.get()); + } + public static void add(Var x,String friendlyname) { + db.put(friendlyname, x); + } + public static void set(Var x,String friendlyname) { + db.put(friendlyname, x); + + + + } + public static void main(String[] args) { + setup(); + String x="test"; + Var a=new Var("Testing"); + add(a,x); + session(); + a.set("sync test"); + Var a2=new Var(new ArrayList()); + add(a2,"arr"); + session(); + } + +} diff --git a/doc/allclasses-frame.html b/doc/allclasses-frame.html new file mode 100644 index 0000000..cbafbbb --- /dev/null +++ b/doc/allclasses-frame.html @@ -0,0 +1,19 @@ + + + + + +All Classes + + + + + +

All Classes

+
+ +
+ + diff --git a/doc/allclasses-noframe.html b/doc/allclasses-noframe.html new file mode 100644 index 0000000..f042cdb --- /dev/null +++ b/doc/allclasses-noframe.html @@ -0,0 +1,19 @@ + + + + + +All Classes + + + + + +

All Classes

+
+ +
+ + diff --git a/doc/class-use/usacotools.html b/doc/class-use/usacotools.html new file mode 100644 index 0000000..1aeafbf --- /dev/null +++ b/doc/class-use/usacotools.html @@ -0,0 +1,122 @@ + + + + + +Uses of Class usacotools + + + + + + + + + + + +
+

Uses of Class
usacotools

+
+
No usage of usacotools
+ + + + + + diff --git a/doc/constant-values.html b/doc/constant-values.html new file mode 100644 index 0000000..2b95edc --- /dev/null +++ b/doc/constant-values.html @@ -0,0 +1,207 @@ + + + + + +Constant Field Values + + + + + + + + + + + +
+

Constant Field Values

+

Contents

+ +
+
+ + +

<Unnamed>.*

+
    +
  • + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    usacotools 
    Modifier and TypeConstant FieldValue
    + +public static final java.lang.StringANSI_BLACK"\u001b[30m"
    + +public static final java.lang.StringANSI_BLUE"\u001b[34m"
    + +public static final java.lang.StringANSI_CYAN"\u001b[36m"
    + +public static final java.lang.StringANSI_GREEN"\u001b[32m"
    + +public static final java.lang.StringANSI_PURPLE"\u001b[35m"
    + +public static final java.lang.StringANSI_RED"\u001b[31m"
    + +public static final java.lang.StringANSI_RESET"\u001b[0m"
    + +public static final java.lang.StringANSI_WHITE"\u001b[37m"
    + +public static final java.lang.StringANSI_YELLOW"\u001b[33m"
    +
  • +
+
+ + + + + + diff --git a/doc/deprecated-list.html b/doc/deprecated-list.html new file mode 100644 index 0000000..cb58035 --- /dev/null +++ b/doc/deprecated-list.html @@ -0,0 +1,122 @@ + + + + + +Deprecated List + + + + + + + + +
+ + + + + + + +
+ + +
+

Deprecated API

+

Contents

+
+ +
+ + + + + + + +
+ + + + diff --git a/doc/help-doc.html b/doc/help-doc.html new file mode 100644 index 0000000..3783254 --- /dev/null +++ b/doc/help-doc.html @@ -0,0 +1,223 @@ + + + + + +API Help + + + + + + + + + + + +
+

How This API Document Is Organized

+
This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.
+
+
+
    +
  • +

    Package

    +

    Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain six categories:

    +
      +
    • Interfaces (italic)
    • +
    • Classes
    • +
    • Enums
    • +
    • Exceptions
    • +
    • Errors
    • +
    • Annotation Types
    • +
    +
  • +
  • +

    Class/Interface

    +

    Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:

    +
      +
    • Class inheritance diagram
    • +
    • Direct Subclasses
    • +
    • All Known Subinterfaces
    • +
    • All Known Implementing Classes
    • +
    • Class/interface declaration
    • +
    • Class/interface description
    • +
    +
      +
    • Nested Class Summary
    • +
    • Field Summary
    • +
    • Constructor Summary
    • +
    • Method Summary
    • +
    +
      +
    • Field Detail
    • +
    • Constructor Detail
    • +
    • Method Detail
    • +
    +

    Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.

    +
  • +
  • +

    Annotation Type

    +

    Each annotation type has its own separate page with the following sections:

    +
      +
    • Annotation Type declaration
    • +
    • Annotation Type description
    • +
    • Required Element Summary
    • +
    • Optional Element Summary
    • +
    • Element Detail
    • +
    +
  • +
  • +

    Enum

    +

    Each enum has its own separate page with the following sections:

    +
      +
    • Enum declaration
    • +
    • Enum description
    • +
    • Enum Constant Summary
    • +
    • Enum Constant Detail
    • +
    +
  • +
  • +

    Use

    +

    Each documented package, class and interface has its own Use page. This page describes what packages, classes, methods, constructors and fields use any part of the given class or package. Given a class or interface A, its Use page includes subclasses of A, fields declared as A, methods that return A, and methods and constructors with parameters of type A. You can access this page by first going to the package, class or interface, then clicking on the "Use" link in the navigation bar.

    +
  • +
  • +

    Tree (Class Hierarchy)

    +

    There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object.

    +
      +
    • When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
    • +
    • When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.
    • +
    +
  • +
  • +

    Deprecated API

    +

    The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.

    +
  • +
  • +

    Index

    +

    The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.

    +
  • +
  • +

    Prev/Next

    +

    These links take you to the next or previous class, interface, package, or related page.

    +
  • +
  • +

    Frames/No Frames

    +

    These links show and hide the HTML frames. All pages are available with or without frames.

    +
  • +
  • +

    All Classes

    +

    The All Classes link shows all classes and interfaces except non-static nested types.

    +
  • +
  • +

    Serialized Form

    +

    Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.

    +
  • +
  • +

    Constant Field Values

    +

    The Constant Field Values page lists the static final fields and their values.

    +
  • +
+This help file applies to API documentation generated using the standard doclet.
+ + + + + + diff --git a/doc/index-files/index-1.html b/doc/index-files/index-1.html new file mode 100644 index 0000000..b09c537 --- /dev/null +++ b/doc/index-files/index-1.html @@ -0,0 +1,143 @@ + + + + + +A-Index + + + + + + + + +
+ + + + + + + +
+ + +
A B C D E G I L M P R T U  + + +

A

+
+
ANSI_BLACK - Static variable in class usacotools
+
 
+
ANSI_BLUE - Static variable in class usacotools
+
 
+
ANSI_CYAN - Static variable in class usacotools
+
 
+
ANSI_GREEN - Static variable in class usacotools
+
 
+
ANSI_PURPLE - Static variable in class usacotools
+
 
+
ANSI_RED - Static variable in class usacotools
+
 
+
ANSI_RESET - Static variable in class usacotools
+
 
+
ANSI_WHITE - Static variable in class usacotools
+
 
+
ANSI_YELLOW - Static variable in class usacotools
+
 
+
+A B C D E G I L M P R T U 
+ +
+ + + + + + + +
+ + + + diff --git a/doc/index-files/index-10.html b/doc/index-files/index-10.html new file mode 100644 index 0000000..c383259 --- /dev/null +++ b/doc/index-files/index-10.html @@ -0,0 +1,133 @@ + + + + + +P-Index + + + + + + + + +
+ + + + + + + +
+ + +
A B C D E G I L M P R T U  + + +

P

+
+
print(String) - Static method in class usacotools
+
 
+
print(String, String) - Static method in class usacotools
+
 
+
print(String, boolean) - Static method in class usacotools
+
 
+
printf(String) - Static method in class usacotools
+
 
+
+A B C D E G I L M P R T U 
+ +
+ + + + + + + +
+ + + + diff --git a/doc/index-files/index-11.html b/doc/index-files/index-11.html new file mode 100644 index 0000000..1fbe94a --- /dev/null +++ b/doc/index-files/index-11.html @@ -0,0 +1,139 @@ + + + + + +R-Index + + + + + + + + +
+ + + + + + + +
+ + +
A B C D E G I L M P R T U  + + +

R

+
+
repeat(int, String) - Static method in class usacotools
+
 
+
report(Exception) - Static method in class usacotools
+
 
+
reverse(int[]) - Static method in class usacotools
+
 
+
reverseh(int[][]) - Static method in class usacotools
+
 
+
reversev(int[][]) - Static method in class usacotools
+
 
+
rotate90cw(int[][]) - Static method in class usacotools
+
 
+
run(String) - Static method in class usacotools
+
 
+
+A B C D E G I L M P R T U 
+ +
+ + + + + + + +
+ + + + diff --git a/doc/index-files/index-12.html b/doc/index-files/index-12.html new file mode 100644 index 0000000..eaf7b80 --- /dev/null +++ b/doc/index-files/index-12.html @@ -0,0 +1,131 @@ + + + + + +T-Index + + + + + + + + +
+ + + + + + + +
+ + +
A B C D E G I L M P R T U  + + +

T

+
+
toArray(ArrayList<Integer>) - Static method in class usacotools
+
 
+
toArrays(ArrayList<String>) - Static method in class usacotools
+
 
+
touching(int[][], int, int) - Static method in class usacotools
+
 
+
+A B C D E G I L M P R T U 
+ +
+ + + + + + + +
+ + + + diff --git a/doc/index-files/index-13.html b/doc/index-files/index-13.html new file mode 100644 index 0000000..25102b9 --- /dev/null +++ b/doc/index-files/index-13.html @@ -0,0 +1,129 @@ + + + + + +U-Index + + + + + + + + +
+ + + + + + + +
+ + +
A B C D E G I L M P R T U  + + +

U

+
+
usacotools - Class in <Unnamed>
+
 
+
usacotools() - Constructor for class usacotools
+
 
+
+A B C D E G I L M P R T U 
+ +
+ + + + + + + +
+ + + + diff --git a/doc/index-files/index-2.html b/doc/index-files/index-2.html new file mode 100644 index 0000000..ffcc4dd --- /dev/null +++ b/doc/index-files/index-2.html @@ -0,0 +1,131 @@ + + + + + +B-Index + + + + + + + + +
+ + + + + + + +
+ + +
A B C D E G I L M P R T U  + + +

B

+
+
benchmark() - Static method in class usacotools
+
 
+
benchmark2() - Static method in class usacotools
+
 
+
binarySearch(int[], int, int, int) - Static method in class usacotools
+
 
+
+A B C D E G I L M P R T U 
+ +
+ + + + + + + +
+ + + + diff --git a/doc/index-files/index-3.html b/doc/index-files/index-3.html new file mode 100644 index 0000000..06a51b6 --- /dev/null +++ b/doc/index-files/index-3.html @@ -0,0 +1,133 @@ + + + + + +C-Index + + + + + + + + +
+ + + + + + + +
+ + +
A B C D E G I L M P R T U  + + +

C

+
+
changen(int, char, String) - Static method in class usacotools
+
 
+
clear() - Static method in class usacotools
+
 
+
console - Static variable in class usacotools
+
 
+
console() - Static method in class usacotools
+
 
+
+A B C D E G I L M P R T U 
+ +
+ + + + + + + +
+ + + + diff --git a/doc/index-files/index-4.html b/doc/index-files/index-4.html new file mode 100644 index 0000000..ec504c0 --- /dev/null +++ b/doc/index-files/index-4.html @@ -0,0 +1,127 @@ + + + + + +D-Index + + + + + + + + +
+ + + + + + + +
+ + +
A B C D E G I L M P R T U  + + +

D

+
+
debugcode - Static variable in class usacotools
+
 
+
+A B C D E G I L M P R T U 
+ +
+ + + + + + + +
+ + + + diff --git a/doc/index-files/index-5.html b/doc/index-files/index-5.html new file mode 100644 index 0000000..4c70919 --- /dev/null +++ b/doc/index-files/index-5.html @@ -0,0 +1,139 @@ + + + + + +E-Index + + + + + + + + +
+ + + + + + + +
+ + +
A B C D E G I L M P R T U  + + +

E

+
+
ebs(int[], int, int, int) - Static method in class usacotools
+
 
+
EMSG - Static variable in class usacotools
+
 
+
error - Static variable in class usacotools
+
 
+
ERRORS - Static variable in class usacotools
+
 
+
ESTACK - Static variable in class usacotools
+
 
+
exit() - Static method in class usacotools
+
 
+
exit(int) - Static method in class usacotools
+
 
+
+A B C D E G I L M P R T U 
+ +
+ + + + + + + +
+ + + + diff --git a/doc/index-files/index-6.html b/doc/index-files/index-6.html new file mode 100644 index 0000000..073f48f --- /dev/null +++ b/doc/index-files/index-6.html @@ -0,0 +1,127 @@ + + + + + +G-Index + + + + + + + + +
+ + + + + + + +
+ + +
A B C D E G I L M P R T U  + + +

G

+
+
getsysscan() - Static method in class usacotools
+
 
+
+A B C D E G I L M P R T U 
+ +
+ + + + + + + +
+ + + + diff --git a/doc/index-files/index-7.html b/doc/index-files/index-7.html new file mode 100644 index 0000000..3e60f2b --- /dev/null +++ b/doc/index-files/index-7.html @@ -0,0 +1,127 @@ + + + + + +I-Index + + + + + + + + +
+ + + + + + + +
+ + +
A B C D E G I L M P R T U  + + +

I

+
+
isrect(int[][], int, int) - Static method in class usacotools
+
 
+
+A B C D E G I L M P R T U 
+ +
+ + + + + + + +
+ + + + diff --git a/doc/index-files/index-8.html b/doc/index-files/index-8.html new file mode 100644 index 0000000..5bd151c --- /dev/null +++ b/doc/index-files/index-8.html @@ -0,0 +1,127 @@ + + + + + +L-Index + + + + + + + + +
+ + + + + + + +
+ + +
A B C D E G I L M P R T U  + + +

L

+
+
lsearch(int[], int) - Static method in class usacotools
+
 
+
+A B C D E G I L M P R T U 
+ +
+ + + + + + + +
+ + + + diff --git a/doc/index-files/index-9.html b/doc/index-files/index-9.html new file mode 100644 index 0000000..30ad7d6 --- /dev/null +++ b/doc/index-files/index-9.html @@ -0,0 +1,131 @@ + + + + + +M-Index + + + + + + + + +
+ + + + + + + +
+ + +
A B C D E G I L M P R T U  + + +

M

+
+
main(String[]) - Static method in class usacotools
+
 
+
mreader(String) - Static method in class usacotools
+
 
+
mwriter(String) - Static method in class usacotools
+
 
+
+A B C D E G I L M P R T U 
+ +
+ + + + + + + +
+ + + + diff --git a/doc/index.html b/doc/index.html new file mode 100644 index 0000000..685d2e7 --- /dev/null +++ b/doc/index.html @@ -0,0 +1,72 @@ + + + + + +Generated Documentation (Untitled) + + + + + + +<noscript> +<div>JavaScript is disabled on your browser.</div> +</noscript> +<h2>Frame Alert</h2> +<p>This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to <a href="usacotools.html">Non-frame version</a>.</p> + + + diff --git a/doc/overview-tree.html b/doc/overview-tree.html new file mode 100644 index 0000000..075aceb --- /dev/null +++ b/doc/overview-tree.html @@ -0,0 +1,131 @@ + + + + + +Class Hierarchy + + + + + + + + + + + +
+

Hierarchy For All Packages

+
+
+

Class Hierarchy

+ +
+ + + + + + diff --git a/doc/package-frame.html b/doc/package-frame.html new file mode 100644 index 0000000..49ff39d --- /dev/null +++ b/doc/package-frame.html @@ -0,0 +1,20 @@ + + + + + +<Unnamed> + + + + + +

<Unnamed>

+
+

Classes

+ +
+ + diff --git a/doc/package-list b/doc/package-list new file mode 100644 index 0000000..d3f5a12 --- /dev/null +++ b/doc/package-list @@ -0,0 +1 @@ + diff --git a/doc/package-summary.html b/doc/package-summary.html new file mode 100644 index 0000000..292f3e4 --- /dev/null +++ b/doc/package-summary.html @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + +
+

Package <Unnamed>

+
+
+
    +
  • + + + + + + + + + + + + +
    Class Summary 
    ClassDescription
    usacotools 
    +
  • +
+
+ + + + + + diff --git a/doc/package-tree.html b/doc/package-tree.html new file mode 100644 index 0000000..d719e72 --- /dev/null +++ b/doc/package-tree.html @@ -0,0 +1,131 @@ + + + + + + Class Hierarchy + + + + + + + + + + + +
+

Hierarchy For Package <Unnamed>

+
+
+

Class Hierarchy

+ +
+ + + + + + diff --git a/doc/package-use.html b/doc/package-use.html new file mode 100644 index 0000000..5f02a4f --- /dev/null +++ b/doc/package-use.html @@ -0,0 +1,122 @@ + + + + + +Uses of Package + + + + + + + + + + + +
+

Uses of Package

+
+
No usage of
+ + + + + + diff --git a/doc/script.js b/doc/script.js new file mode 100644 index 0000000..c3a1cae --- /dev/null +++ b/doc/script.js @@ -0,0 +1,30 @@ +function show(type) +{ + count = 0; + for (var key in methods) { + var row = document.getElementById(key); + if ((methods[key] & type) != 0) { + row.style.display = ''; + row.className = (count++ % 2) ? rowColor : altColor; + } + else + row.style.display = 'none'; + } + updateTabs(type); +} + +function updateTabs(type) +{ + for (var value in tabs) { + var sNode = document.getElementById(tabs[value][0]); + var spanNode = sNode.firstChild; + if (value == type) { + sNode.className = activeTableTab; + spanNode.innerHTML = tabs[value][1]; + } + else { + sNode.className = tableTab; + spanNode.innerHTML = "" + tabs[value][1] + ""; + } + } +} diff --git a/doc/stylesheet.css b/doc/stylesheet.css new file mode 100644 index 0000000..b8dad08 --- /dev/null +++ b/doc/stylesheet.css @@ -0,0 +1,574 @@ +/* Javadoc style sheet */ +/* +Overall document style +*/ + +@import url('resources/fonts/dejavu.css'); + +body { + background-color:#ffffff; + color:#353833; + font-family:'DejaVu Sans', Arial, Helvetica, sans-serif; + font-size:14px; + margin:0; +} +a:link, a:visited { + text-decoration:none; + color:#4A6782; +} +a:hover, a:focus { + text-decoration:none; + color:#bb7a2a; +} +a:active { + text-decoration:none; + color:#4A6782; +} +a[name] { + color:#353833; +} +a[name]:hover { + text-decoration:none; + color:#353833; +} +pre { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; +} +h1 { + font-size:20px; +} +h2 { + font-size:18px; +} +h3 { + font-size:16px; + font-style:italic; +} +h4 { + font-size:13px; +} +h5 { + font-size:12px; +} +h6 { + font-size:11px; +} +ul { + list-style-type:disc; +} +code, tt { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + padding-top:4px; + margin-top:8px; + line-height:1.4em; +} +dt code { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + padding-top:4px; +} +table tr td dt code { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + vertical-align:top; + padding-top:4px; +} +sup { + font-size:8px; +} +/* +Document title and Copyright styles +*/ +.clear { + clear:both; + height:0px; + overflow:hidden; +} +.aboutLanguage { + float:right; + padding:0px 21px; + font-size:11px; + z-index:200; + margin-top:-9px; +} +.legalCopy { + margin-left:.5em; +} +.bar a, .bar a:link, .bar a:visited, .bar a:active { + color:#FFFFFF; + text-decoration:none; +} +.bar a:hover, .bar a:focus { + color:#bb7a2a; +} +.tab { + background-color:#0066FF; + color:#ffffff; + padding:8px; + width:5em; + font-weight:bold; +} +/* +Navigation bar styles +*/ +.bar { + background-color:#4D7A97; + color:#FFFFFF; + padding:.8em .5em .4em .8em; + height:auto;/*height:1.8em;*/ + font-size:11px; + margin:0; +} +.topNav { + background-color:#4D7A97; + color:#FFFFFF; + float:left; + padding:0; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; + font-size:12px; +} +.bottomNav { + margin-top:10px; + background-color:#4D7A97; + color:#FFFFFF; + float:left; + padding:0; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; + font-size:12px; +} +.subNav { + background-color:#dee3e9; + float:left; + width:100%; + overflow:hidden; + font-size:12px; +} +.subNav div { + clear:left; + float:left; + padding:0 0 5px 6px; + text-transform:uppercase; +} +ul.navList, ul.subNavList { + float:left; + margin:0 25px 0 0; + padding:0; +} +ul.navList li{ + list-style:none; + float:left; + padding: 5px 6px; + text-transform:uppercase; +} +ul.subNavList li{ + list-style:none; + float:left; +} +.topNav a:link, .topNav a:active, .topNav a:visited, .bottomNav a:link, .bottomNav a:active, .bottomNav a:visited { + color:#FFFFFF; + text-decoration:none; + text-transform:uppercase; +} +.topNav a:hover, .bottomNav a:hover { + text-decoration:none; + color:#bb7a2a; + text-transform:uppercase; +} +.navBarCell1Rev { + background-color:#F8981D; + color:#253441; + margin: auto 5px; +} +.skipNav { + position:absolute; + top:auto; + left:-9999px; + overflow:hidden; +} +/* +Page header and footer styles +*/ +.header, .footer { + clear:both; + margin:0 20px; + padding:5px 0 0 0; +} +.indexHeader { + margin:10px; + position:relative; +} +.indexHeader span{ + margin-right:15px; +} +.indexHeader h1 { + font-size:13px; +} +.title { + color:#2c4557; + margin:10px 0; +} +.subTitle { + margin:5px 0 0 0; +} +.header ul { + margin:0 0 15px 0; + padding:0; +} +.footer ul { + margin:20px 0 5px 0; +} +.header ul li, .footer ul li { + list-style:none; + font-size:13px; +} +/* +Heading styles +*/ +div.details ul.blockList ul.blockList ul.blockList li.blockList h4, div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 { + background-color:#dee3e9; + border:1px solid #d0d9e0; + margin:0 0 6px -8px; + padding:7px 5px; +} +ul.blockList ul.blockList ul.blockList li.blockList h3 { + background-color:#dee3e9; + border:1px solid #d0d9e0; + margin:0 0 6px -8px; + padding:7px 5px; +} +ul.blockList ul.blockList li.blockList h3 { + padding:0; + margin:15px 0; +} +ul.blockList li.blockList h2 { + padding:0px 0 20px 0; +} +/* +Page layout container styles +*/ +.contentContainer, .sourceContainer, .classUseContainer, .serializedFormContainer, .constantValuesContainer { + clear:both; + padding:10px 20px; + position:relative; +} +.indexContainer { + margin:10px; + position:relative; + font-size:12px; +} +.indexContainer h2 { + font-size:13px; + padding:0 0 3px 0; +} +.indexContainer ul { + margin:0; + padding:0; +} +.indexContainer ul li { + list-style:none; + padding-top:2px; +} +.contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt { + font-size:12px; + font-weight:bold; + margin:10px 0 0 0; + color:#4E4E4E; +} +.contentContainer .description dl dd, .contentContainer .details dl dd, .serializedFormContainer dl dd { + margin:5px 0 10px 0px; + font-size:14px; + font-family:'DejaVu Sans Mono',monospace; +} +.serializedFormContainer dl.nameValue dt { + margin-left:1px; + font-size:1.1em; + display:inline; + font-weight:bold; +} +.serializedFormContainer dl.nameValue dd { + margin:0 0 0 1px; + font-size:1.1em; + display:inline; +} +/* +List styles +*/ +ul.horizontal li { + display:inline; + font-size:0.9em; +} +ul.inheritance { + margin:0; + padding:0; +} +ul.inheritance li { + display:inline; + list-style:none; +} +ul.inheritance li ul.inheritance { + margin-left:15px; + padding-left:15px; + padding-top:1px; +} +ul.blockList, ul.blockListLast { + margin:10px 0 10px 0; + padding:0; +} +ul.blockList li.blockList, ul.blockListLast li.blockList { + list-style:none; + margin-bottom:15px; + line-height:1.4; +} +ul.blockList ul.blockList li.blockList, ul.blockList ul.blockListLast li.blockList { + padding:0px 20px 5px 10px; + border:1px solid #ededed; + background-color:#f8f8f8; +} +ul.blockList ul.blockList ul.blockList li.blockList, ul.blockList ul.blockList ul.blockListLast li.blockList { + padding:0 0 5px 8px; + background-color:#ffffff; + border:none; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockList { + margin-left:0; + padding-left:0; + padding-bottom:15px; + border:none; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast { + list-style:none; + border-bottom:none; + padding-bottom:0; +} +table tr td dl, table tr td dl dt, table tr td dl dd { + margin-top:0; + margin-bottom:1px; +} +/* +Table styles +*/ +.overviewSummary, .memberSummary, .typeSummary, .useSummary, .constantsSummary, .deprecatedSummary { + width:100%; + border-left:1px solid #EEE; + border-right:1px solid #EEE; + border-bottom:1px solid #EEE; +} +.overviewSummary, .memberSummary { + padding:0px; +} +.overviewSummary caption, .memberSummary caption, .typeSummary caption, +.useSummary caption, .constantsSummary caption, .deprecatedSummary caption { + position:relative; + text-align:left; + background-repeat:no-repeat; + color:#253441; + font-weight:bold; + clear:none; + overflow:hidden; + padding:0px; + padding-top:10px; + padding-left:1px; + margin:0px; + white-space:pre; +} +.overviewSummary caption a:link, .memberSummary caption a:link, .typeSummary caption a:link, +.useSummary caption a:link, .constantsSummary caption a:link, .deprecatedSummary caption a:link, +.overviewSummary caption a:hover, .memberSummary caption a:hover, .typeSummary caption a:hover, +.useSummary caption a:hover, .constantsSummary caption a:hover, .deprecatedSummary caption a:hover, +.overviewSummary caption a:active, .memberSummary caption a:active, .typeSummary caption a:active, +.useSummary caption a:active, .constantsSummary caption a:active, .deprecatedSummary caption a:active, +.overviewSummary caption a:visited, .memberSummary caption a:visited, .typeSummary caption a:visited, +.useSummary caption a:visited, .constantsSummary caption a:visited, .deprecatedSummary caption a:visited { + color:#FFFFFF; +} +.overviewSummary caption span, .memberSummary caption span, .typeSummary caption span, +.useSummary caption span, .constantsSummary caption span, .deprecatedSummary caption span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + padding-bottom:7px; + display:inline-block; + float:left; + background-color:#F8981D; + border: none; + height:16px; +} +.memberSummary caption span.activeTableTab span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + margin-right:3px; + display:inline-block; + float:left; + background-color:#F8981D; + height:16px; +} +.memberSummary caption span.tableTab span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + margin-right:3px; + display:inline-block; + float:left; + background-color:#4D7A97; + height:16px; +} +.memberSummary caption span.tableTab, .memberSummary caption span.activeTableTab { + padding-top:0px; + padding-left:0px; + padding-right:0px; + background-image:none; + float:none; + display:inline; +} +.overviewSummary .tabEnd, .memberSummary .tabEnd, .typeSummary .tabEnd, +.useSummary .tabEnd, .constantsSummary .tabEnd, .deprecatedSummary .tabEnd { + display:none; + width:5px; + position:relative; + float:left; + background-color:#F8981D; +} +.memberSummary .activeTableTab .tabEnd { + display:none; + width:5px; + margin-right:3px; + position:relative; + float:left; + background-color:#F8981D; +} +.memberSummary .tableTab .tabEnd { + display:none; + width:5px; + margin-right:3px; + position:relative; + background-color:#4D7A97; + float:left; + +} +.overviewSummary td, .memberSummary td, .typeSummary td, +.useSummary td, .constantsSummary td, .deprecatedSummary td { + text-align:left; + padding:0px 0px 12px 10px; +} +th.colOne, th.colFirst, th.colLast, .useSummary th, .constantsSummary th, +td.colOne, td.colFirst, td.colLast, .useSummary td, .constantsSummary td{ + vertical-align:top; + padding-right:0px; + padding-top:8px; + padding-bottom:3px; +} +th.colFirst, th.colLast, th.colOne, .constantsSummary th { + background:#dee3e9; + text-align:left; + padding:8px 3px 3px 7px; +} +td.colFirst, th.colFirst { + white-space:nowrap; + font-size:13px; +} +td.colLast, th.colLast { + font-size:13px; +} +td.colOne, th.colOne { + font-size:13px; +} +.overviewSummary td.colFirst, .overviewSummary th.colFirst, +.useSummary td.colFirst, .useSummary th.colFirst, +.overviewSummary td.colOne, .overviewSummary th.colOne, +.memberSummary td.colFirst, .memberSummary th.colFirst, +.memberSummary td.colOne, .memberSummary th.colOne, +.typeSummary td.colFirst{ + width:25%; + vertical-align:top; +} +td.colOne a:link, td.colOne a:active, td.colOne a:visited, td.colOne a:hover, td.colFirst a:link, td.colFirst a:active, td.colFirst a:visited, td.colFirst a:hover, td.colLast a:link, td.colLast a:active, td.colLast a:visited, td.colLast a:hover, .constantValuesContainer td a:link, .constantValuesContainer td a:active, .constantValuesContainer td a:visited, .constantValuesContainer td a:hover { + font-weight:bold; +} +.tableSubHeadingColor { + background-color:#EEEEFF; +} +.altColor { + background-color:#FFFFFF; +} +.rowColor { + background-color:#EEEEEF; +} +/* +Content styles +*/ +.description pre { + margin-top:0; +} +.deprecatedContent { + margin:0; + padding:10px 0; +} +.docSummary { + padding:0; +} + +ul.blockList ul.blockList ul.blockList li.blockList h3 { + font-style:normal; +} + +div.block { + font-size:14px; + font-family:'DejaVu Serif', Georgia, "Times New Roman", Times, serif; +} + +td.colLast div { + padding-top:0px; +} + + +td.colLast a { + padding-bottom:3px; +} +/* +Formatting effect styles +*/ +.sourceLineNo { + color:green; + padding:0 30px 0 0; +} +h1.hidden { + visibility:hidden; + overflow:hidden; + font-size:10px; +} +.block { + display:block; + margin:3px 10px 2px 0px; + color:#474747; +} +.deprecatedLabel, .descfrmTypeLabel, .memberNameLabel, .memberNameLink, +.overrideSpecifyLabel, .packageHierarchyLabel, .paramLabel, .returnLabel, +.seeLabel, .simpleTagLabel, .throwsLabel, .typeNameLabel, .typeNameLink { + font-weight:bold; +} +.deprecationComment, .emphasizedPhrase, .interfaceName { + font-style:italic; +} + +div.block div.block span.deprecationComment, div.block div.block span.emphasizedPhrase, +div.block div.block span.interfaceName { + font-style:normal; +} + +div.contentContainer ul.blockList li.blockList h2{ + padding-bottom:0px; +} diff --git a/doc/usacotools.html b/doc/usacotools.html new file mode 100644 index 0000000..99b85b5 --- /dev/null +++ b/doc/usacotools.html @@ -0,0 +1,933 @@ + + + + + +usacotools + + + + + + + + + + + + +
+

Class usacotools

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • usacotools
    • +
    +
  • +
+
+
    +
  • +
    +
    +
    public abstract class usacotools
    +extends java.lang.Object
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Field Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Fields 
      Modifier and TypeField and Description
      static java.lang.StringANSI_BLACK 
      static java.lang.StringANSI_BLUE 
      static java.lang.StringANSI_CYAN 
      static java.lang.StringANSI_GREEN 
      static java.lang.StringANSI_PURPLE 
      static java.lang.StringANSI_RED 
      static java.lang.StringANSI_RESET 
      static java.lang.StringANSI_WHITE 
      static java.lang.StringANSI_YELLOW 
      static java.util.ArrayList<java.lang.Exception>console 
      static intdebugcode 
      static booleanEMSG 
      static java.lang.Stringerror 
      static intERRORS 
      static booleanESTACK 
      +
    • +
    + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + +
      Constructors 
      Constructor and Description
      usacotools() 
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      All Methods Static Methods Concrete Methods 
      Modifier and TypeMethod and Description
      static longbenchmark() 
      static longbenchmark2() 
      static intbinarySearch(int[] arr, + int l, + int r, + int x) 
      static java.lang.Stringchangen(int position, + char ch, + java.lang.String str) 
      static voidclear() 
      static voidconsole() 
      static intebs(int[] arr, + int l, + int r, + int x) 
      static voidexit() 
      static voidexit(int code) 
      static java.util.Scannergetsysscan() 
      static booleanisrect(int[][] map, + int x, + int y) 
      static intlsearch(int[] a, + int b) 
      static voidmain(java.lang.String[] args) 
      static java.io.BufferedReadermreader(java.lang.String filen) 
      static java.io.PrintWritermwriter(java.lang.String filen) 
      static voidprint(java.lang.String out) 
      static voidprint(java.lang.String out, + boolean flush) 
      static voidprint(java.lang.String out, + java.lang.String end) 
      static voidprintf(java.lang.String out) 
      static java.lang.Stringrepeat(int count, + java.lang.String with) 
      static voidreport(java.lang.Exception e) 
      static int[]reverse(int[] a) 
      static int[][]reverseh(int[][] a) 
      static int[][]reversev(int[][] a) 
      static int[][]rotate90cw(int[][] map) 
      static voidrun(java.lang.String exe) 
      static int[]toArray(java.util.ArrayList<java.lang.Integer> arr) 
      static java.lang.String[]toArrays(java.util.ArrayList<java.lang.String> arr) 
      static java.util.ArrayList<java.lang.Integer>touching(int[][] map, + int x, + int y) 
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        ANSI_RESET

        +
        public static final java.lang.String ANSI_RESET
        +
        +
        See Also:
        +
        Constant Field Values
        +
        +
      • +
      + + + +
        +
      • +

        ANSI_BLACK

        +
        public static final java.lang.String ANSI_BLACK
        +
        +
        See Also:
        +
        Constant Field Values
        +
        +
      • +
      + + + + + + + +
        +
      • +

        ANSI_GREEN

        +
        public static final java.lang.String ANSI_GREEN
        +
        +
        See Also:
        +
        Constant Field Values
        +
        +
      • +
      + + + +
        +
      • +

        ANSI_YELLOW

        +
        public static final java.lang.String ANSI_YELLOW
        +
        +
        See Also:
        +
        Constant Field Values
        +
        +
      • +
      + + + + + + + +
        +
      • +

        ANSI_PURPLE

        +
        public static final java.lang.String ANSI_PURPLE
        +
        +
        See Also:
        +
        Constant Field Values
        +
        +
      • +
      + + + + + + + +
        +
      • +

        ANSI_WHITE

        +
        public static final java.lang.String ANSI_WHITE
        +
        +
        See Also:
        +
        Constant Field Values
        +
        +
      • +
      + + + +
        +
      • +

        ERRORS

        +
        public static int ERRORS
        +
      • +
      + + + +
        +
      • +

        console

        +
        public static java.util.ArrayList<java.lang.Exception> console
        +
      • +
      + + + +
        +
      • +

        error

        +
        public static java.lang.String error
        +
      • +
      + + + +
        +
      • +

        debugcode

        +
        public static int debugcode
        +
      • +
      + + + +
        +
      • +

        ESTACK

        +
        public static boolean ESTACK
        +
      • +
      + + + +
        +
      • +

        EMSG

        +
        public static boolean EMSG
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        usacotools

        +
        public usacotools()
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        isrect

        +
        public static boolean isrect(int[][] map,
        +                             int x,
        +                             int y)
        +
      • +
      + + + +
        +
      • +

        report

        +
        public static void report(java.lang.Exception e)
        +
      • +
      + + + +
        +
      • +

        touching

        +
        public static java.util.ArrayList<java.lang.Integer> touching(int[][] map,
        +                                                              int x,
        +                                                              int y)
        +
      • +
      + + + +
        +
      • +

        repeat

        +
        public static java.lang.String repeat(int count,
        +                                      java.lang.String with)
        +
      • +
      + + + +
        +
      • +

        changen

        +
        public static java.lang.String changen(int position,
        +                                       char ch,
        +                                       java.lang.String str)
        +
      • +
      + + + +
        +
      • +

        mreader

        +
        public static java.io.BufferedReader mreader(java.lang.String filen)
        +                                      throws java.io.IOException
        +
        +
        Throws:
        +
        java.io.IOException
        +
        +
      • +
      + + + +
        +
      • +

        mwriter

        +
        public static java.io.PrintWriter mwriter(java.lang.String filen)
        +                                   throws java.io.IOException
        +
        +
        Throws:
        +
        java.io.IOException
        +
        +
      • +
      + + + +
        +
      • +

        getsysscan

        +
        public static java.util.Scanner getsysscan()
        +
      • +
      + + + +
        +
      • +

        binarySearch

        +
        public static int binarySearch(int[] arr,
        +                               int l,
        +                               int r,
        +                               int x)
        +
      • +
      + + + +
        +
      • +

        ebs

        +
        public static int ebs(int[] arr,
        +                      int l,
        +                      int r,
        +                      int x)
        +
      • +
      + + + +
        +
      • +

        lsearch

        +
        public static int lsearch(int[] a,
        +                          int b)
        +
      • +
      + + + +
        +
      • +

        print

        +
        public static void print(java.lang.String out)
        +
      • +
      + + + +
        +
      • +

        printf

        +
        public static void printf(java.lang.String out)
        +
      • +
      + + + +
        +
      • +

        print

        +
        public static void print(java.lang.String out,
        +                         java.lang.String end)
        +
      • +
      + + + +
        +
      • +

        print

        +
        public static void print(java.lang.String out,
        +                         boolean flush)
        +
      • +
      + + + +
        +
      • +

        toArray

        +
        public static int[] toArray(java.util.ArrayList<java.lang.Integer> arr)
        +
      • +
      + + + +
        +
      • +

        toArrays

        +
        public static java.lang.String[] toArrays(java.util.ArrayList<java.lang.String> arr)
        +
      • +
      + + + +
        +
      • +

        exit

        +
        public static void exit()
        +
      • +
      + + + +
        +
      • +

        exit

        +
        public static void exit(int code)
        +
      • +
      + + + +
        +
      • +

        benchmark

        +
        public static long benchmark()
        +
      • +
      + + + +
        +
      • +

        benchmark2

        +
        public static long benchmark2()
        +
      • +
      + + + +
        +
      • +

        clear

        +
        public static void clear()
        +
      • +
      + + + +
        +
      • +

        console

        +
        public static void console()
        +
      • +
      + + + +
        +
      • +

        run

        +
        public static void run(java.lang.String exe)
        +
      • +
      + + + +
        +
      • +

        reverse

        +
        public static int[] reverse(int[] a)
        +
      • +
      + + + +
        +
      • +

        reverseh

        +
        public static int[][] reverseh(int[][] a)
        +
      • +
      + + + +
        +
      • +

        reversev

        +
        public static int[][] reversev(int[][] a)
        +
      • +
      + + + +
        +
      • +

        rotate90cw

        +
        public static int[][] rotate90cw(int[][] map)
        +
      • +
      + + + +
        +
      • +

        main

        +
        public static void main(java.lang.String[] args)
        +                 throws java.lang.Exception
        +
        +
        Throws:
        +
        java.lang.Exception
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + + + diff --git a/index.htm b/index.htm new file mode 100644 index 0000000..393a061 --- /dev/null +++ b/index.htm @@ -0,0 +1,27 @@ + + + + + + + + + + +Code Speed + + + + + + + +

Which runs faster on java

+ + + + + + diff --git a/usacotools.java b/usacotools.java index 2edc111..f7ed572 100644 --- a/usacotools.java +++ b/usacotools.java @@ -1,6 +1,24 @@ - +/* + * USACOTOOLS-Official version + * This is the official version. + * + */ +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Queue; +import java.util.Scanner; +import java.util.Set; import java.util.*; -import java.io.*; +import java.util.regex.*; public abstract class usacotools { public static final String ANSI_RESET = "\u001B[0m"; public static final String ANSI_BLACK = "\u001B[30m"; @@ -15,6 +33,12 @@ public abstract class usacotools { public static ArrayList console=new ArrayList(); public static String error="Error"; public static int debugcode=-1; + public static boolean DEBUG=false; + public static boolean lock; + public static boolean IO=true; + public static void blockio() { + IO=false; + } public static boolean isrect(int[][] map,int x,int y) { int cachedsize=-1; int cachey=-1; @@ -34,6 +58,38 @@ public static boolean isrect(int[][] map,int x,int y) { } return true; } + public static Set sclones(Set k) { + return (new HashSet(k)); + } + public static Set sclone(Set k) { + + return (new HashSet(k)); + } + public static Set sclonel(Set k) { + return (new HashSet(k)); + } + public static boolean smartequals(int[] a,int[] b) { + if(a.length!=b.length) { + return false; + } + for(int i=0;i arr) { + if(!(lock)) {return null;} int[] stuff=new int[arr.size()]; for(int i=0;i arr) { } public static String[] toArrays(ArrayList arr) { + if(!(lock)) {return null;} String[] stuff=new String[arr.size()]; for(int i=0;i fibmem=new ArrayList(); + public static long ffib(long n){ + /* + * Fibonnaci implemented with DP + */ + if(n<=1) { + return n; + } + + if(fibmem.size()>n) { + return fibmem.get((int) n-1)+fibmem.get((int) n-2); + }else { + fibmem.add(ffib(n-1)+ffib(n-2)); + return fibmem.get((int) n); + } + } + public static void print() { + System.out.println(); + } + public static void setupfib() { + fibmem.add((long) 0);fibmem.add((long)1);fibmem.add((long)1);fibmem.add((long)2); + } + public static void show2Darr(int[][] a) { + //Print out a 2D array for you + for(int[] b:a) { + for(int c:b) { + print(c+" ",""); + } + print(); + + } + } + public static void showarr(int[] a) { + //Print out a array for you + for(int x:a) {print(x+" ");} + } + public static int[][] dpcache; + public static int ks(int W,int[] wt,int[] val,int n) { + int result; + if(dpcache[n][W]!=0) {return dpcache[n][W];} + if(n==0||W==0) { + result=0; + }else if(wt[n-1]>W) { + result=ks(W,wt,val,n-1); + + + + }else { + result=Math.max(val[n-1]+ks(W-wt[n-1],wt,val,n-1),ks(W,wt,val,n-1)); + } + dpcache[n][W]=result; + return result; + } + public static void kssetup(int n,int W) { + dpcache=new int[n+1][W+1]; + } + public static int count(int[] arr) { /* - * Short demo of stuff - * Making an error would also demo error reporting - * + * Number of groups of 1s + * Modify for other purposes if needed + * Example + * 1111000111 + * Returns 2 * */ - System.out.println("Running demo"); - Scanner sc=getsysscan(); - print("Welcome to the demo\nYou have many choices \n1} Run help \n2} Check for a update \n3}Run demo to see features"); - print(">",""); - int val; - try { - val=sc.nextInt(); - }catch(Exception e) { - print("Oops that did not go well please rerun and choose a INTEGER"); - val=-1; - report(e); - print("How about we test erro reporting"); - console(); + boolean b=false;int c=0;int temp; + for(int i=0;i speedqueue=new LinkedList(); + public static long prevtime=0; + public static void $1() { + long time=System.currentTimeMillis(); + if(prevtime==0) { + prevtime=time; + }else { + speedqueue.add((long) abs(time-prevtime)); + prevtime=0; } } + public static long $r() { + return speedqueue.poll().longValue(); + } + public static boolean $r$smatch(String a,String b) { + return Pattern.matches(a, b); + } + public static boolean $r$match(String a,String b) throws Exception{ + //WIP + throw new Exception("Not implemented"); + } } diff --git a/utools.java b/utools.java new file mode 100644 index 0000000..83bfe5f --- /dev/null +++ b/utools.java @@ -0,0 +1,494 @@ +/* + * USACOTOOLS-Official version + * This is the official version. + * + */ +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Queue; +import java.util.Scanner; +import java.util.Set; +import java.util.*; +import java.util.regex.*; +public abstract class utools { + public static final String ANSI_RESET = "\u001B[0m"; + public static final String ANSI_BLACK = "\u001B[30m"; + public static final String ANSI_RED = "\u001B[31m"; + public static final String ANSI_GREEN = "\u001B[32m"; + public static final String ANSI_YELLOW = "\u001B[33m"; + public static final String ANSI_BLUE = "\u001B[34m"; + public static final String ANSI_PURPLE = "\u001B[35m"; + public static final String ANSI_CYAN = "\u001B[36m"; + public static final String ANSI_WHITE = "\u001B[37m"; + public static int ERRORS=0; + public static ArrayList console=new ArrayList(); + public static String error="Error"; + public static int debugcode=-1; + public static boolean DEBUG=false; + public static boolean lock; + public static boolean IO=true; + public static void blockio() { + IO=false; + } + public static boolean isrect(int[][] map,int x,int y) { + int cachedsize=-1; + int cachey=-1; + for(int i=x;icachedsize) { + return false; + } + for(int j=y;jcachey) { + return false; + } + } + } + return true; + } + public static Set sclones(Set k) { + return (new HashSet(k)); + } + public static Set sclone(Set k) { + + return (new HashSet(k)); + } + public static Set sclonel(Set k) { + return (new HashSet(k)); + } + public static boolean smartequals(int[] a,int[] b) { + if(a.length!=b.length) { + return false; + } + for(int i=0;i touching(int[][] map,int x,int y){ + ArrayList out=new ArrayList(); + try { + out.add(map[x-1][y]); + }catch(Exception e) { + + } + try { + out.add(map[x+1][y]); + }catch(Exception e) { + + } + try { + out.add(map[x][y-1]); + }catch(Exception e) { + + } + try { + out.add(map[x][y+1]); + }catch(Exception e) { + + } + return out; + + } + public static String repeat(int count, String with) { + return new String(new char[count]).replace("\0", with); + } + public static String changen(int position, char ch, String str){ + char[] charArray = str.toCharArray(); + charArray[position] = ch; + return new String(charArray); + } + public static BufferedReader mreader(String filen) throws IOException { + //Make a reader + return new BufferedReader(new FileReader(filen)); + } + public static PrintWriter mwriter(String filen) throws IOException { + return new PrintWriter(new BufferedWriter(new FileWriter(filen))); + } + public static Scanner getsysscan() { + return new Scanner(System.in); + } + public static int binarySearch(int arr[], int l, int r, int x) + { + /* + * Binary Search + * + */ + if (r>=l) + { + int mid = l + (r - l)/2; + + + if (arr[mid] == x) + return mid; + + if (arr[mid] > x) + return binarySearch(arr, l, mid-1, x); + + return binarySearch(arr, mid+1, r, x); + } + + + return -1; + } + public static int[][] copy2D(int[][] a){ + + int[][] b=new int[a.length][]; + for(int i=0;i arr) { + + int[] stuff=new int[arr.size()]; + for(int i=0;i arr) { + + String[] stuff=new String[arr.size()]; + for(int i=0;i fibmem=new ArrayList(); + public static long ffib(long n){ + /* + * Fibonnaci implemented with DP + */ + if(n<=1) { + return n; + } + + if(fibmem.size()>n) { + return fibmem.get((int) n-1)+fibmem.get((int) n-2); + }else { + fibmem.add(ffib(n-1)+ffib(n-2)); + return fibmem.get((int) n); + } + } + public static void print() { + System.out.println(); + } + public static void setupfib() { + fibmem.add((long) 0);fibmem.add((long)1);fibmem.add((long)1);fibmem.add((long)2); + } + public static void show2Darr(int[][] a) { + //Print out a 2D array for you + for(int[] b:a) { + for(int c:b) { + print(c+" ",""); + } + print(); + + } + } + public static void showarr(int[] a) { + //Print out a array for you + for(int x:a) {print(x+" ");} + } + public static int[][] dpcache; + public static int ks(int W,int[] wt,int[] val,int n) { + int result; + if(dpcache[n][W]!=0) {return dpcache[n][W];} + if(n==0||W==0) { + result=0; + }else if(wt[n-1]>W) { + result=ks(W,wt,val,n-1); + + + + }else { + result=Math.max(val[n-1]+ks(W-wt[n-1],wt,val,n-1),ks(W,wt,val,n-1)); + } + dpcache[n][W]=result; + return result; + } + public static void kssetup(int n,int W) { + dpcache=new int[n+1][W+1]; + } + public static int count(int[] arr) { + /* + * Number of groups of 1s + * Modify for other purposes if needed + * Example + * 1111000111 + * Returns 2 + * + */ + boolean b=false;int c=0;int temp; + for(int i=0;i speedqueue=new LinkedList(); + public static long prevtime=0; + public static void $1() { + long time=System.currentTimeMillis(); + if(prevtime==0) { + prevtime=time; + }else { + speedqueue.add((long) abs(time-prevtime)); + prevtime=0; + } + } + public static long $r() { + return speedqueue.poll().longValue(); + } + public static boolean $r$smatch(String a,String b) { + return Pattern.matches(a, b); + } + public static boolean $r$match(String a,String b) throws Exception{ + //WIP + throw new Exception("Not implemented"); + } +} +