Nyoj 81 kinds of sorting

Source: Internet
Author: User

Time limit:MS | Memory limit:65535 KB Difficulty:3
Describe
Now there are a lot of rectangles, each rectangle has a number, this number can be repeated, also know that the width and length of the rectangle, the number, length, width are all integers; now it's required to sort by a bit (the default collation is small to large);

1. Sort by number from small to large

2. For the numbers equal to the rectangle, according to the oblong long sort;

3. If the numbers and lengths are the same, sort by the width of the rectangle;

4. If the number, length, and width are the same, only one rectangle is reserved for sorting, the extra rectangles are removed, and the final sequence displays all rectangles in the specified format;
Input
The first line has an integer 0<n<10000, which indicates that there is an n set of test data next.
The first line of each group has an integer 0<m<1000, which indicates that there is a m rectangle;
The next M-line, each line has three numbers, the first number represents the number of rectangles,

The second and third numeric representations are long, the values are small, the representation is wide, equal
Description This is a square (data contract length width and number are less than 10000);
Output
sequential output The number length of all eligible rectangles for each set of data
Sample input
181 1 11 1 11 1 21 2 11 2 22 1 12 1 22 2 1
Sample output
1 1 11 2 11 2 22 1 12 2 1
1 /*************************************************************************2 > File name:8.cpp3 > Author:markfo4 > Mail: [email protected]5 > Created time:2018-02-12 17:09:376  ************************************************************************/7 8#include <iostream>9#include <algorithm>Ten#include <string.h> One#include <string> A#include <stdio.h> -#include <stdlib.h> - using namespacestd; the  - structnode{ -     intA; -     intb; +     intC; - }; +  A BOOLCMP (node Node1, node Node2) at { -     if(node1.a! =node2.a) -     { -         returnnode1.a <node2.a; -     } -     Else if(node1.b! =node2.b) in     { -         returnnode1.b <node2.b; to     } +     Else if(node1.c! =node2.c) -     { the         returnnode1.c <node2.c; *     } $ }Panax Notoginseng  - intMain () the { +     intT; ANode arr[1005]; theCIN >>T; +      while(t--) -     { $         inttt; $CIN >>tt; -          for(inti =0; I < TT; ++i) -         { theCIN >> arr[i].a >> arr[i].b >>arr[i].c; -             if(Arr[i].b <arr[i].c)Wuyi             { the                 inttmp; -TMP =arr[i].b; WuARR[I].B =arr[i].c; -ARR[I].C =tmp; About             } $         } -  -Stable_sort (arr, arr+TT, CMP); -  A         intflag[1005] = {0}; +          for(inti =1; I < TT; ++i) the         { -             if(ARR[I].A = = arr[i-1].A && arr[i].b = = arr[i-1].b && arr[i].c = = arr[i-1].c) $             { theFlag[i] =1; the             } the         } the          -          for(inti =0; I < TT; ++i) in         { the             if(Flag[i] = =0) the             { Aboutcout << arr[i].a <<" "<< arr[i].b <<" "<< arr[i].c <<Endl; the             } the         } the     } +  -     return 0; the}

Nyoj 81 kinds of sorting

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.