3 条题解
-
0
#include <bits/stdc++.h> using namespace std; struct Product { int p, c; unordered_set<int> features; }; int main() { int n, m; cin >> n >> m; vector<Product> products(n + 1); // 1-based indexing for (int i = 1; i <= n; i++) { cin >> products[i].p >> products[i].c; for (int j = 0; j < products[i].c; j++) { int f; cin >> f; products[i].features.insert(f); } } bool found = false; for (int i = 1; i <= n && !found; i++) { for (int j = 1; j <= n && !found; j++) { if (i == j) continue; const Product &a = products[i]; const Product &b = products[j]; // Check P_i >= P_j if (a.p >= b.p) { // Check if all features of a are in b (a.features is subset of b.features) bool all_features_included = true; for (int f : a.features) { if (b.features.find(f) == b.features.end()) { all_features_included = false; break; } } if (all_features_included) { // Check P_i > P_j or b has extra features (b.features is not subset of a.features) if (a.p > b.p) { found = true; break; } else { // Check if b has at least one feature not in a bool b_has_extra = false; for (int f : b.features) { if (a.features.find(f) == a.features.end()) { b_has_extra = true; break; } } if (b_has_extra) { found = true; break; } } } } } } cout << (found ? "Yes" : "No") << endl; return 0; } -
0
#include<bits/stdc++.h> using namespace std; const int N=110; struct node{int x;set<int>s;}a[N]; int main() { int n,m;cin>>n>>m; for(int i=1;i<=n;i++) { cin>>a[i].x;int l;cin>>l; for(int j=1,y;j<=l;j++)cin>>y,a[i].s.insert(y); } for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)if(i!=j&&a[i].x>=a[j].x) { bool bk=0; for(int y:a[i].s)if(!a[j].s.count(y)){bk=1;break;} if(bk)continue; bk=0; for(int y:a[j].s)if(!a[i].s.count(y)){bk=1;break;} if(bk||a[i].x>a[j].x){cout<<"Yes";return 0;} } cout<<"No"; return 0; } -
0
#include<bits/stdc++.h> using namespace std; struct nd{int p,c,f[110];}a[110]; bool cmp(nd n1,nd n2){return n1.p<n2.p;} int main() { int n,m;scanf("%d%d",&n,&m); for(int i=1;i<=n;i++) { scanf("%d%d",&a[i].p,&a[i].c); for(int j=1;j<=a[i].c;j++) scanf("%d",&a[i].f[j]); sort(a[i].f+1,a[i].f+a[i].c+1); } sort(a+1,a+n+1,cmp); for(int j=1;j<n;j++)for(int i=j+1;i<=n;i++) { int k=1;bool bk=0; for(int t=1;t<=a[j].c;t++) { if(a[j].f[t]==a[i].f[k])k++; if(k>a[i].c){bk=1;break;} } if(bk==0)continue; if(a[i].p>a[j].p||a[j].c>a[i].c) { puts("Yes"); return 0; } } puts("No"); return 0; }
- 1
信息
- ID
- 8900
- 时间
- 2000ms
- 内存
- 1024MiB
- 难度
- 5
- 标签
- 递交数
- 50
- 已通过
- 19
- 上传者