View Code of Problem 5

#include <iostream> 
#include <stdlib.h>
#include <stdio.h>
#include <algorithm>
#include <stack>
#include <math.h>
#include <string.h>
using namespace std;
struct A {
	int x;
	int y;
	int mark;
};
int cmp(A t1, A t2) {
	if (t1.x > t2.x)
		return 1;
	else if (t1.x == t2.x&&t1.y >= t2.y)
		return 1;
	else
		return 0;
}
int main() {
	A s[100];
	int T;
	cin >> T;
	while (T--) {
		int n, m;
		cin >> n >> m;
		for (int i = 0; i < n; i++) {
			cin >> s[i].x>>s[i].y;
			s[i].mark = i + 1;
		}
		sort(s, s + n, cmp);
		for (int i = 0; i < m; i++)
			cout << s[i].mark << " ";
		cout << endl;
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 5