QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#732353#9573. Social Mediaqinglu09#WA 15ms14240kbC++231.5kb2024-11-10 14:09:012024-11-10 14:09:01

Judging History

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

  • [2024-11-10 14:09:01]
  • 评测
  • 测评结果:WA
  • 用时:15ms
  • 内存:14240kb
  • [2024-11-10 14:09:01]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define endl '\n'
#define debug(x) cout<<#x<<": "<<x<<endl
const int N=2e5+10;

map<ll, ll>mp[N];
bool vis[N];
ll g[N];

void solve()
{
    ll n, k, m, ans = 0, s = 0;
    cin >> n >> m >> k;
    rep(i, 1, k)
    {
        mp[i].clear();
        vis[i] = 0;
        g[i] = 0;
    }
    rep(i, 1, n)
    {
        ll x;
        cin >> x;
        vis[x] = 1;
    }
    rep(i, 1, m)
    {
        ll u, v;
        cin >> u >> v;
        if(vis[u] && vis[v])
        {
            s++;
        }
        else if(vis[u])
        {
            g[v]++;
        }
        else if(vis[v])
        {
            g[u]++;
        }
        else if(u == v)
        {
            g[u]++;
        }
        else
        {
            mp[u][v]++;
            mp[v][u]++;
        }
    }
    ans = s;
    rep(i, 1, k)
    {
        ll res = g[i] + s;
        for(auto [x, y] : mp[i])
        {
            ans = max(ans, res + y + g[x]);
        }
    }
    sort(g + 1, g + k + 1);
    if(k != 1) ans = max(ans, g[k] + g[k - 1]);
    else ans = max(ans, g[k]);
    cout << ans << endl;
}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
// #ifndef  ONLINEJUDGE
//     freopen("test.in","r",stdin);
//     freopen("test.out","w",stdout);
// #endif
    int T;
    cin>>T;
    while(T--)
    {
        solve();
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 13232kb

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: 15ms
memory: 14240kb

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:

10
14
1
19
3
5
1
11
19
3
3
8
4
1
4
13
12
2
13
4
17
3
1
2
5
17
3
2
3
12
6
3
4
3
2
7
3
7
4
1
16
15
2
3
5
12
9
7
4
6
7
6
8
11
16
1
4
6
8
14
2
6
19
15
16
8
20
12
5
10
7
5
6
8
2
13
9
5
5
3
6
6
20
7
13
11
10
5
3
5
3
1
5
3
7
11
7
13
9
9
6
6
7
8
4
1
8
9
10
5
2
3
5
10
1
6
8
16
5
3
19
1
4
6
8
10
4
2
1
14
1
8
...

result:

wrong answer 1st numbers differ - expected: '12', found: '10'