fork(1) download
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4. import java.io.PrintWriter;
  5.  
  6. class Spoj
  7. {
  8. public static void main(String[] args) throws IOException
  9. {
  10. PrintWriter pw = new PrintWriter(System.out, true);
  11. int test = Integer.parseInt(br.readLine());
  12. while (test > 0)
  13. {
  14. int liczba_punktow = Integer.parseInt(br.readLine());
  15. Wspolrzedna[] tab = new Wspolrzedna[liczba_punktow];
  16. for (int i = 0; i < liczba_punktow; i++)
  17. {
  18. String[] str_tab = br.readLine().split(" ");
  19. tab[i] = new Wspolrzedna(str_tab[0], Integer.parseInt(str_tab[1]), Integer.parseInt(str_tab[2]));
  20. }
  21. Sortowanie(tab);
  22. for (int i = 0; i < liczba_punktow; i++)
  23. pw.printf("%s %d %d\n", tab[i].nazwa, tab[i].x, tab[i].y);
  24. String to_nic_nie_robi_poza_enterem = br.readLine();
  25. to_nic_nie_robi_poza_enterem = "Musze cos tu wpisac";
  26. pw.println();
  27. --test;
  28. }
  29.  
  30. }
  31.  
  32. public static void Sortowanie(Wspolrzedna[] tab)
  33. {
  34. int size = tab.length - 1;
  35. for (int i = 0; i < tab.length - 1; i++)
  36. {
  37. for (int j = 0; j < size; j++)
  38. {
  39. if (tab[j].iloczyn > tab[j + 1].iloczyn)
  40. {
  41. Wspolrzedna temp = tab[j];
  42. tab[j] = tab[j + 1];
  43. tab[j + 1] = temp;
  44. }
  45. }
  46. size--;
  47. }
  48. }
  49. }
  50.  
  51. class Wspolrzedna
  52. {
  53. String nazwa;
  54. int x;
  55. int y;
  56. int iloczyn;
  57.  
  58. public Wspolrzedna(String n, int x, int y)
  59. {
  60. nazwa = n;
  61. this.x = x;
  62. this.y = y;
  63. iloczyn = Math.abs(this.x) * Math.abs(this.y);
  64. }
  65. }
Success #stdin #stdout 0.08s 381184KB
stdin
2
3
A 0 0
C 5 5
B 1 -1

1
X 1 1
stdout
A 0 0
B 1 -1
C 5 5

X 1 1