QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#746539 | #9573. Social Media | sea_bird | WA | 21ms | 5916kb | C++20 | 1.9kb | 2024-11-14 14:57:02 | 2024-11-14 14:57:03 |
Judging History
answer
#include<bits/stdc++.h>
typedef long long ll;
const int maxn = 2e5 + 100;
int f[maxn];
using pii = std::pair<int,int>;
pii arr[maxn];
void solve(){
int n,m,k;
std::cin >> n >> m >> k;
std::fill(f + 1,f + 1 + k,0);
for(int i = 0;i < n;i++){
int op;
std::cin >> op;
f[op] = 1;
}
std::map<pii,int>mp;
std::map<int,int>cnt;
int ans = 0;
for(int i = 1;i <= m;i++){
std::cin >> arr[i].first >> arr[i].second;
if(arr[i].first > arr[i].second)std::swap(arr[i].first,arr[i].second);
if(arr[i].first == arr[i].second){
if(f[arr[i].first])ans++;
else cnt[arr[i].first]++;
}
if(f[arr[i].first]){
if(f[arr[i].second]){
ans++;
}
else{
cnt[arr[i].second]++;
}
}
else{
if(f[arr[i].second]){
cnt[arr[i].first]++;
}
else{
mp[arr[i]]++;
}
}
}
int mx = 0,mix = 0;
for(auto [x,w] : cnt){
if(w >= mx){
mix = mx;
mx = w;
}
else if(w > mix){
mix = w;
}
}
// std::cout << ans << " " << mx << " " << mix << "\n";
int res = ans + mx + mix;
for(int i = 1;i <= m;i++){
if(f[arr[i].first] == 0 and
f[arr[i].second] == 0
and arr[i].first != arr[i].second){
res = std::max(res,ans + cnt[arr[i].first] + cnt[arr[i].second] + mp[arr[i]]);
// if(res == 11){
// std::cout << arr[i].first << " " << arr[i].second << "\n";
// }
}
}
std::cout << res << "\n";
}
int main(){
std::ios::sync_with_stdio(0);
std::cin.tie(0),std::cout.tie(0);
int t;
std::cin >> t;
while(t--){
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 5548kb
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: 21ms
memory: 5916kb
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 6 5 1 14 19 4 3 10 4 1 4 20 15 2 18 4 17 6 1 2 5 20 3 3 6 15 7 3 6 4 5 7 3 7 4 1 17 16 2 3 6 13 13 7 7 9 8 7 9 11 16 1 4 9 8 16 2 8 22 25 17 8 22 15 10 13 8 9 6 9 2 18 10 5 5 3 6 6 20 8 13 12 12 5 4 6 3 1 8 6 8 12 7 16 11 9 10 11 9 9 6 2 8 15 11 5 3 5 5 12 1 6 9 18 5 3 20 1 5 8 9 10 4 3 1...
result:
wrong answer 8th numbers differ - expected: '11', found: '14'