Advertisement
Guest User

Java 8 Template - ArtyKing

a guest
Sep 15th, 2020
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.94 KB | None | 0 0
  1. import java.io.*;
  2. public class Main {
  3.     static BufferedReader br; static FileWriter fw; static PrintWriter pw; static StringTokenizer st;
  4.     static String next () throws IOException {
  5.         while (st == null || !st.hasMoreTokens())
  6.             st = new StringTokenizer(br.readLine().trim());
  7.         return st.nextToken();
  8.     }
  9.     static long readLong () throws IOException {
  10.         return Long.parseLong(next());
  11.     }
  12.     static int readInt () throws IOException {
  13.         return Integer.parseInt(next());
  14.     }
  15.     static short readShort () throws IOException {
  16.         return Short.parseShort(next());
  17.     }
  18.     static double readDouble () throws IOException {
  19.         return Double.parseDouble(next());
  20.     }
  21.     static char readChar () throws IOException {
  22.         return next().charAt(0);
  23.     }
  24.     static String readLine () throws IOException {
  25.         return br.readLine().trim();
  26.     }
  27.     static void init(int n) {
  28.         adj = new ArrayList[n];
  29.         for(int i = 0; i < n; i++) {
  30.             adj[i] = new ArrayList<>();
  31.         }
  32.     }
  33.     static class Pair implements Comparable<Pair>{
  34.         int x; int y; boolean isValid = true;
  35.         public Pair(int a, int b) {
  36.             x = a; y = b;
  37.         }
  38.         public String toString() {
  39.             return ("("+x+", "+y+")");
  40.         }
  41.         @Override
  42.         public boolean equals(Object c) {
  43.             if(c == null) return false;
  44.             Pair t = (Pair) c;
  45.             if(t.x == x && t.y == y) return true;
  46.             return false;
  47.         }
  48.         public int compareTo(Pair a) {
  49.             if(a.x==x) {
  50.                 return -Integer.compare(y, a.y);
  51.             }
  52.             return Integer.compare(x, a.x);
  53.         }
  54.     }
  55.     static class Edge implements Comparable<Edge>{
  56.         int u, v, w;
  57.         public Edge(int u, int v) {
  58.             this.u = u; this.v = v; this.w = 1;
  59.         }
  60.         public Edge(int u, int v, int w) {
  61.             this.u = u; this.v = v; this.w = w;
  62.         }
  63.         public String toString() {
  64.             return "Edge from "+u+" to "+v+" with weight "+w;
  65.         }
  66.         public int compareTo(Edge e) {
  67.             return Integer.compare(w,e.w);
  68.         }
  69.     }
  70.     public static void main(String[] args) throws IOException{
  71.         if(dmoj) {
  72.             br = new BufferedReader(new InputStreamReader(System.in));
  73.             pw = new PrintWriter(System.out);
  74.         }
  75.         else {
  76.             //Configure output here
  77.             br = new BufferedReader(new FileReader("input.txt"));
  78.             fw = new FileWriter("output.txt");
  79.             pw = new PrintWriter(fw);
  80.         }
  81.         if(doCases) {
  82.             int t = readInt();
  83.             for(int i = 0; i < t; i++) {
  84.                 solve();
  85.             }
  86.         }
  87.         else solve();
  88.         pw.close();
  89.     }
  90.     //------------------------------------------------------------
  91.     static boolean doCases = false; static boolean dmoj = true;
  92.     static List<Pair> adj[];
  93.     static void solve() throws IOException {
  94.  
  95.     }
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement