QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#732174 | #9573. Social Media | mhw# | WA | 84ms | 4204kb | C++23 | 1.3kb | 2024-11-10 13:33:49 | 2024-11-10 13:33:49 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using i64 = long long;
const i64 P = 998244353;
const int N = 1e5 + 5;
void solve() {
int n, k, m, ans = 0, res = 0;
cin >> n >> k >> m;
vector<int> a(n), v(N), c(m + 1);
vector<int> p1(k), p2(k);
for (int i = 0; i < n; i++) {
cin >> a[i];
v[a[i]] = 1;
}
map<pair<int, int>, int> mp;
for (int i = 0; i < k; i++) {
cin >> p1[i] >> p2[i];
if (p1[i] > p2[i]) swap(p1[i], p2[i]);
if (v[p1[i]] && v[p2[i]]) {
ans++;
} else if (v[p1[i]]) {
c[p2[i]]++;
} else if (v[p2[i]]) {
c[p1[i]]++;
} else {
if (p2[i] == p1[i]) {
c[p2[i]]++;
} else {
mp[{p1[i], p2[i]}]++;
}
}
}
for (int i = 0; i < k; i++) {
if (p1[i] != p2[i]) res = max(res, c[p1[i]] + c[p2[i]] + mp[{p1[i], p2[i]}]);
else res = max(res, p1[i]);
}
sort(c.begin(), c.end(), greater<>());
int tmp = 0;
for (int i = 0; i < min(2, (int)c.size()); i++) tmp += c[i];
res = max(tmp, res);
cout << ans + res << '\n';
}
int main() {
ios::sync_with_stdio(0); cin.tie(0), cout.tie(0);
int t = 1;
cin >> t;
while (t--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 4204kb
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:
9 5 1 1 1
result:
ok 5 number(s): "9 5 1 1 1"
Test #2:
score: -100
Wrong Answer
time: 84ms
memory: 3940kb
input:
10000 19 12 20 8 12 1 5 11 7 17 13 19 6 3 9 10 15 14 20 4 18 16 4 11 7 1 8 4 16 19 1 13 15 2 16 2 8 7 3 15 11 13 5 20 18 14 17 14 20 2 9 1 12 8 11 10 17 18 16 3 15 5 14 20 13 7 15 10 3 2 5 16 7 8 6 1 6 4 18 16 1 8 4 1 20 6 6 9 4 15 7 5 14 9 1 3 18 9 15 18 17 15 11 14 7 19 7 3 1 2 5 6 4 7 5 1 4 5 3 1...
output:
12 14 1 19 12 5 1 13 19 4 3 10 14 3 4 19 15 2 18 4 17 5 1 2 5 20 3 3 6 15 10 16 13 4 8 7 3 7 16 1 16 23 2 3 6 12 16 7 12 8 8 21 12 11 16 1 14 9 8 32 2 12 25 21 27 8 28 16 13 21 13 9 6 13 2 27 26 5 5 3 10 6 20 8 13 21 19 5 3 6 11 1 8 12 8 27 7 25 12 9 11 11 21 9 6 2 21 14 30 5 3 5 8 23 1 6 13 23 5 4 ...
result:
wrong answer 5th numbers differ - expected: '6', found: '12'