Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package a2oj;
- import java.io.BufferedReader;
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.InputStreamReader;
- import java.io.OutputStream;
- import java.io.PrintWriter;
- import java.util.Arrays;
- import java.util.Comparator;
- import java.util.StringTokenizer;
- /**
- * Created by rakshit on 7/1/17.
- * Java is Love and Code is Beautiful..
- */
- public class Laptop {
- static class InputReader
- {
- public BufferedReader reader;
- public StringTokenizer tok;
- public InputReader(InputStream inputStream)
- {
- reader =new BufferedReader(new InputStreamReader(inputStream));
- tok=null;
- }
- public InputReader(String inputFile) throws FileNotFoundException
- {
- reader=new BufferedReader(new FileReader(inputFile));
- tok=null;
- }
- public String nextLine()
- {
- String c="";
- try
- {
- c+=reader.readLine();
- }
- catch(IOException e)
- {
- throw new RuntimeException(e);
- }
- return c;
- }
- public String next()
- {
- while(tok==null || !tok.hasMoreTokens())
- {
- try
- {
- tok=new StringTokenizer(nextLine());
- }
- catch(Exception e)
- {
- throw new RuntimeException(e);
- }
- }
- return tok.nextToken();
- }
- public int nextInt()
- {
- return Integer.parseInt(next());
- }
- public long nextLong()
- {
- return Long.parseLong(next());
- }
- public double nextDouble()
- {
- return Double.parseDouble(next());
- }
- }
- public static void main(String args[])
- {
- InputStream inputstream=System.in;
- OutputStream outputstream=System.out;
- InputReader in=new InputReader(inputstream);
- PrintWriter out=new PrintWriter (outputstream);
- Task solver=new Task();
- solver.solve(in,out);
- }
- static class Task
- {
- public void solve(InputReader in , PrintWriter out)
- {
- int n=in.nextInt();
- Store store[]=new Store[n];
- int a,b,c,d;
- for(int i=0 ;i<n ;i++)
- {
- a=in.nextInt();
- b=in.nextInt();
- c=in.nextInt();
- d=in.nextInt();
- store[i].set1(a);
- store[i].set2(b);
- store[i].set3(c);
- store[i].set4(d);
- }
- Arrays.sort(store, new comparator());
- for(int i=0 ;i<n ;i++)
- {
- out.println(store[i].get1()+" "+store[i].get2()+" "+store[i].get3()+" "+store[i].get4());
- }
- out.flush();
- }
- }
- static class Store
- {
- private static int a;
- private static int b;
- private static int c;
- private static int d;
- public Store(int a, int b,int c,int d)
- {
- this.a=a;
- this.b=b;
- this.c=c;
- this.a=a;
- }
- public int get1()
- {
- return a;
- }
- public int get2()
- {
- return b;
- }
- public int get3()
- {
- return c;
- }
- public int get4()
- {
- return d;
- }
- public void set1(int a)
- {
- this.a=a;
- }
- public void set2(int b)
- {
- this.b=b;
- }
- public void set3(int c)
- {
- this.c=c;
- }
- public void set4(int d)
- {
- this.d=d;
- }
- }
- static class comparator implements Comparator<Store>
- {
- public int compare(Store one, Store two)
- {
- if(one.a<two.a)
- {
- return -1;
- }
- else if(one.a>two.a)
- {
- return 1;
- }
- else
- {
- if(one.b<two.b)
- {
- return -1;
- }
- else if(one.b>two.b)
- {
- return 1;
- }
- else
- {
- if(one.c<two.c)
- {
- return -1;
- }
- else if(one.c>two.c)
- {
- return 1;
- }
- else
- {
- if(one.d<two.d)
- {
- return -1;
- }
- else if(one.d>two.d)
- {
- return 1;
- }
- else
- return 0;
- }
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment