没有很好的思路,求解释。
查看原帖
没有很好的思路,求解释。
172240
kuaiCreator楼主2024/12/20 13:30
#include<bits/stdc++.h>
using namespace std;
struct robot {
	int mj, ll;
} rob[200005], res;
bool cmp(robot a, robot b) {
	return a.mj > b.mj;
}
int main() {
	int n;
	cin >> n;
	if (n == 1) {
		cout << "NIE";
		return 0;
	}
	for (int i = 1; i <= n; i++) cin >> rob[i].mj >> rob[i].ll;
	sort(rob + 1, rob + 1 + n, cmp);
	int i = 1, j = 2, def = 0;
	while (i <= n && j <= n) {
		while (j <= n && rob[i].mj > rob[j].mj && rob[i].ll > rob[j].ll) {
			j++;
			def++;
		}
		i = j;
		j = i + 1;
	}
	if ((n - def) & 1) cout << "NIE";
	else cout << "TAK";
	return 0;
}
2024/12/20 13:30
加载中...