Today, we found out that there was such a magic DD-stable_sort after refreshing Ural 1100. The function is to use multiple values, sort by the third parameter without changing the appearance order of other values... Er, it's hard to understand. Let's get started with it.
Http://acm.timus.ru/problem.aspx? Space = 1 & num = 1100
# Include <vector> # include <list> # include <map> # include <set> # include <queue> # include <string. h> # include <deque> # include <stack> # include <bitset> # include <algorithm> # include <functional> # include <numeric> # include <utility> # include <sstream> # include <iostream> # include <iomanip> # include <cstdio> # include <cmath> # include <cstdlib> # include <limits. h> using namespace STD; # define ll long # define PI ACOs (-1) # define n 150010 # define INF int_max # define EPS 1e-8 //************************** ***************** // Ural 1100 //*************** * ***************************** struct node {int ID; int val;} e [N]; bool CMP (node A, Node B) {return. val> B. val;} int main () {// freopen ("a.txt", "r", stdin); int N; while (scanf ("% d", & N )! = EOF) {int I, j; for (I = 0; I <n; I ++) scanf ("% d", & E [I]. ID, & E [I]. val); stable_sort (E, E + N, CMP); // stable sorting. If the order is the same, the order for (I = 0; I <N; I ++) printf ("% d \ n", E [I]. ID, E [I]. val);} return 0 ;}