求调
  • 板块CF1949F Dating
  • 楼主Exile_Code
  • 当前回复0
  • 已保存回复0
  • 发布时间2025/2/1 20:29
  • 上次更新2025/2/2 10:52:09
查看原帖
求调
819682
Exile_Code楼主2025/2/1 20:29
#include <bits/stdc++.h>
using namespace std;


#define inf64 INT64_MAX/2
#define inf32 INT32_MAX/2
#define ll long long
#define int ll
#define pii pair<int,int>
#define endl '\n'
#define vv vector
#define cy cout<<"Yes"<<endl
#define cn cout<<"No"<<endl
#define its(a)  a.begin() + 1,a.end()
#define minV *min_element
#define maxV *max_element

int _;
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
//数学公式
ll mpow(ll x, ll y, ll mod);




void solve() {

	int n; cin >> n;
	int m; cin >> m;

	vv<pair<int, vv<int>>>all(n + 1);

	for (int i = 1; i <= n; i++) {
		int sz; cin >> sz;
		while (sz--) {
			int a; cin >> a;
			all[i].second.push_back(a);
		}
		sort(all[i].second.begin(), all[i].second.end());
		all[i].first = i;
	}
	auto cmp = [&](pair<int,vv<int>>& a, pair<int,vv<int>>& b)->int {
		return a.second.size() > b.second.size();
	};
	sort(its(all), cmp);
	vv<int>f(m + 1);

	for (int i = 1; i <= n; i++) {
		int pos = f[all[i].second[0]];
		
		for (auto a : all[i].second) {
			if (f[a] != pos){
				cout << "Yes" << endl;
				cout << all[pos].first << " " << all[i].first << endl;
				return;
			}
			else {
				f[a] = i;
			}
		}

	}
	cout << "NO" << endl;
}
signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);


	_ = 1;
	//cin >> _;

	while (_--) {
		solve();
	}

	return 0;
}


ll mpow(ll x, ll y, ll mod) {
	x %= mod;
	ll s = 1;
	while (y) {
		if (y & 1) {
			s *= x;
			s %= mod;
		}
		x *= x;
		x %= mod;
		y >>= 1;
	}
	return s;
}
2025/2/1 20:29
加载中...