1327B - Princesses and Princes

暴力:

暴力枚举所有人即可

数据有误,第三行应该是2 1,害我调半天

#include <iostream>
#include <vector>
#include <set>
using namespace std;
const int N = 100010;
int n;
set <int> ans;
int main () {
	int T;
	cin >> T;
	while (T--) {
		bool success = false;
		cin >> n;
		ans.clear ();
		for (int i = 1;i <= n;i++) ans.insert (i);
		int idx;
		for (int i = 1;i <= n;i++) {
			int k;
			bool flag = false;
			cin >> k;
			while (k--) {
				int x;
				cin >> x;
				if (ans.count (x) && !flag) {
					ans.erase (x);
					flag = true;
				}
			}
			if (!flag) {
				idx = i;
				success = true;
			}
		}
		if (success) {
			cout << "IMPROVE" << endl;
			cout << idx << ' ' << *ans.begin () << endl;
		}
		else cout << "OPTIMAL" << endl;
	}
	return 0;
}
posted @ 2022-06-18 14:14  incra  阅读(29)  评论(0)    收藏  举报