QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#756834#9573. Social Mediaticking_awayWA 16ms3780kbC++202.1kb2024-11-16 22:11:592024-11-16 22:12:00

Judging History

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

  • [2024-11-16 22:12:00]
  • 评测
  • 测评结果:WA
  • 用时:16ms
  • 内存:3780kb
  • [2024-11-16 22:11:59]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ui = unsigned int;
using ull = unsigned long long;
using ll = long long;
#define endl '\n'
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int maxn = 2e5 + 10;
const int mod = 1000000007;
#define inl inline
#define fr(i, a, b) for (int i = a; i <= b; i++)
#define ford(i, a, b) for (int i = a; i >= b; i--)
#define forall(i, a) for (auto &i : a)

/**
   ____         ___ _____
  / ___| _   _ / _ \___ /
  \___ \| | | | | | ||_ \
   ___) | |_| | |_| |__) |
  |____/ \__, |\___/____/
         |___/
*/
istream &operator>>(istream &in, vector<int> &v)
{
    for (auto &i : v)
        in >> i;
    return in;
}
ostream &operator<<(ostream &out, vector<int> &v)
{
    for (auto &i : v)
        out << i << " ";
    return out;
}
bool _output = 1;

#define int ll
void solve()
{
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> f(k + 1);
    fr(i, 1, n)
    {
        int x;
        cin >> x;
        f[x] = 1;
    }
    int base = 0;
    map<pii, int> mp;
    vector<int> d(k + 1);
    fr(i, 1, m)
    {
        int x, y;
        cin >> x >> y;
        if (x > y)
            swap(x, y);
        if (f[x] && f[y])
        {
            base++;
        }
        else if (!f[x] && !f[y])
        {
            mp[{x, y}]++;
        }
        else if (f[x])
        {
            d[y]++;
        }
        else
            d[x]++;
    }
    int ans = 0;
    pll res = {0, 0};
    for (auto [i, j] : mp)
    {
        auto [u, v] = i;
        ans = max(ans, v + d[u] + d[v]);
    }
    fr(i, 1, k)
    {
        if (!f[i])
        {
            if (d[i] > res.first)
            {
                res = {d[i], res.first};
            }
            else if (d[i] > res.second)
            {
                res.second = d[i];
            }
        }
    }
    ans = max(res.first + res.second, ans);
    cout << ans + base << endl;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int _ = 1;
    if (_output)
        cin >> _;
    while (_--)
        solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3780kb

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: 16ms
memory: 3556kb

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
19
18
19
14
21
17
11
19
4
10
10
14
3
4
19
15
16
18
18
17
9
18
2
19
17
16
2
6
15
6
16
15
22
4
22
3
7
18
1
23
15
16
18
6
31
12
7
6
8
23
18
8
11
16
10
16
9
8
14
15
6
19
19
16
20
20
14
8
12
18
9
6
8
19
29
9
22
13
3
11
8
20
8
28
11
29
5
10
6
19
12
8
5
15
11
7
14
24
9
11
11
7
25
5
2
24
14
10
21
3
5
9
2...

result:

wrong answer 2nd numbers differ - expected: '14', found: '19'