QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#738678 | #9573. Social Media | ucup-team1412 | WA | 0ms | 3860kb | C++23 | 1.7kb | 2024-11-12 19:41:45 | 2024-11-12 19:41:47 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
const ll maxn = 2e5 + 10;
bool fri[maxn];
ll cnt[maxn];
bool cmp(ll a, ll b) {
return a > b;
}
struct edge {
ll u, v;
bool operator<(const edge& b)const {
return u < b.u;
}
};
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
ll t;
cin >> t;
while (t--) {
ll n, m, k;
cin >> n >> m >> k;
map<edge, ll> mp;
for (ll i = 1; i <= k; i++) {
cnt[i] = 0;
fri[i] = false;
}
for (ll i = 1; i <= n; i++) {
ll temp;
cin >> temp;
fri[temp] = true;
}
ll ans = 0;
for (ll i = 1; i <= m; i++) {
ll x, y;
cin >> x >> y;
if (fri[x] && fri[y]) {
ans++;
}
else if ((!fri[x]) && fri[y]) {
cnt[x]++;
}
else if (fri[x] && (!fri[y])) {
cnt[y]++;
}
else {
if (x > y) swap(x, y);
mp[{x, y}]++;
}
}
ll mx = 0;
// for (auto it : vp) {
// ll x = it.first, y = it.second;
// if (mp.find({ x,y }) != mp.end()) {
// mp[{x, y}]++;
// }
// else {
// mp[{x, y}] = cnt[x] + cnt[y];
// }
// }
for (auto it : mp) {
mx = max(mx, it.second + cnt[it.first.u] + cnt[it.first.v]);
}
sort(cnt + 1, cnt + 1 + k, cmp);
ans += max(mx, cnt[1] + cnt[2]);
cout << ans << endl;
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3860kb
input:
5 4 12 7 5 7 3 6 3 6 2 2 1 4 2 4 1 3 7 6 4 1 5 4 1 1 1 1 2 1 3 7 2 7 6 2 4 1 2 3 2 2 5 5 4 2 6 4 6 2 6 1 1 2 1 1 2 2 1 2 1 2 1 2 2 1 100 24 11 11 24
output:
10 5 1 1 1
result:
wrong answer 1st numbers differ - expected: '9', found: '10'