题解:AT_abc448_c [ABC448C] Except and Min
Ashankamiko · · 题解
题意
给定一个数列
思路
排序后直接模拟,找到没被删除的直接输出。
AC 代码
#include <bits/stdc++.h>
using namespace std;
#define in cin
#define out cout
#define int long long
#define ios ios::sync_with_stdio(false), in.tie(nullptr), out.tie(nullptr)
const int N = 3e5 + 5;
int n, m;
struct node {
int x, id;
} a[N];
signed main() {
ios;
in >> n >> m;
for (int i = 1; i <= n; a[i].id = i, i++)
in >> a[i].x;
sort(a + 1, a + n + 1, [](node x, node y) {
return x.x < y.x;
});
while (m--) {
int k;
in >> k;
unordered_set <int> st;
while (k--) {
int x;
in >> x;
st.insert(x);
}
for (int i = 1; i <= n; i++)
if (!st.count(a[i].id)) { //没被删除
out << a[i].x << '\n';
break;
}
}
return 0;
}