社区讨论

没有很好的思路,求解释。

P11385 [POI 2024/2025 R1] Walki robotów参与者 2已保存回复 3

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
3 条
当前快照
1 份
快照标识符
@m4wbb90v
此快照首次捕获于
2024/12/20 13:30
去年
此快照最后确认于
2025/11/04 12:36
4 个月前
查看原帖
CPP
#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;
}

回复

3 条回复,欢迎继续交流。

正在加载回复...