Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.*;
- import java.math.*;
- public class Main {
- private BufferedReader in;
- private PrintWriter out;
- private StringTokenizer st;
- private Random rnd;
- class Record implements Comparable<Record> {
- String date, data;
- int a, b, c, id;
- Record(String _date, String _data, int _a, int _b, int _c, int _id) {
- date = _date;
- data = _data;
- a = _a;
- b = _b;
- c = _c;
- id = _id;
- }
- public int compareTo(Record o) {
- int c1 = this.a - o.a;
- int c2 = this.b - o.b;
- int c3 = this.c - o.c;
- int c4 = this.id - o.id;
- if(c1 != 0) {
- return c1;
- }
- if(c2 != 0) {
- return c2;
- }
- if(c3 != 0) {
- return c3;
- }
- return c4;
- }
- }
- public void solve() throws IOException {
- ArrayList<Record> v = new ArrayList<Record>();
- int id = 0;
- while(true) {
- String line = in.readLine();
- if(line == null) {
- break;
- }
- String[] parts = line.split("\t");
- String[] date_parts = parts[0].split("\\.");
- v.add(new Record(parts[0], parts[1], Integer.parseInt(date_parts[2]), Integer.parseInt(date_parts[1]), Integer.parseInt(date_parts[0]), id++));
- }
- Collections.sort(v);
- for(Record r : v) {
- out.println(r.date + "\t" + r.data);
- }
- }
- public static void main(String[] args) {
- new Main().run();
- }
- public void run() {
- try {
- //System.setIn(new FileInputStream("rating.in"));
- //System.setOut(new PrintStream(new FileOutputStream("rating.out")));
- in = new BufferedReader(new InputStreamReader(System.in));
- out = new PrintWriter(System.out);
- st = null;
- rnd = new Random();
- solve();
- out.close();
- } catch(IOException e) {
- e.printStackTrace();
- }
- }
- private String nextToken() throws IOException, NullPointerException {
- while(st == null || !st.hasMoreTokens()) {
- st = new StringTokenizer(in.readLine());
- }
- return st.nextToken();
- }
- private int nextInt() throws IOException {
- return Integer.parseInt(nextToken());
- }
- private long nextLong() throws IOException {
- return Long.parseLong(nextToken());
- }
- private double nextDouble() throws IOException {
- return Double.parseDouble(nextToken());
- }
- }
Add Comment
Please, Sign In to add comment