QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#738678#9573. Social Mediaucup-team1412WA 0ms3860kbC++231.7kb2024-11-12 19:41:452024-11-12 19:41:47

Judging History

你现在查看的是最新测评结果

  • [2024-11-12 19:41:47]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3860kb
  • [2024-11-12 19:41:45]
  • 提交

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;
}

Details

Tip: Click on the bar to expand more detailed information

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'