QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#729106#9573. Social Mediaucup-team3691#WA 18ms5632kbC++201.8kb2024-11-09 16:30:022024-11-09 16:30:06

Judging History

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

  • [2024-11-09 16:30:06]
  • 评测
  • 测评结果:WA
  • 用时:18ms
  • 内存:5632kb
  • [2024-11-09 16:30:02]
  • 提交

answer

#include <iostream>
#include <map>

using namespace std;
int fre[200005];
int x[200005];
int y[200005];
int cnt[200005];
map<pair<int,int>,int>adj;
int main()
{
    int n,i,j,k,l,t,op,m,a,b,xx;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>t;
    for(op=1;op<=t;op++)
    {
        cin>>n>>m>>k;
        adj.clear();
        for(i=1;i<=k;i++)
        {
            fre[i]=0;
            cnt[i]=0;
        }
        for(i=1;i<=n;i++)
        {
            cin>>xx;
            fre[xx]=1;
        }
        int sol=0,init=0;
        for(i=1;i<=m;i++)
        {
            cin>>a>>b;
            x[i]=a;
            y[i]=a;
            //adj[{a,b}]++;
            if(fre[a]==1 && fre[b]==0)
            {
                cnt[b]++;
            }
            else if(fre[a]==0 && fre[b]==1)
            {
                cnt[a]++;
            }
            else if(fre[a]==1 && fre[b]==1)
            {
                sol++;
            }
            else
            {
                if(a!=b)
                {
                    adj[{a,b}]++;
                }
                else
                {
                    cnt[a]++;
                }
            }
        }
        init=sol;
        int max1=0,max2=0;
        for(i=1;i<=k;i++)
        {
            if(cnt[i]>=max1)
            {
                max2=max1;
                max1=cnt[i];
            }
            else if(cnt[i]>=max2)
            {
                max2=cnt[i];
            }
        }
        sol+=max1+max2;
        for(i=1;i<=m;i++)
        {
            if(fre[x[i]]==0 && fre[y[i]]==0)
            {
                sol=max(sol,init+adj[{x[i],y[i]}]+cnt[x[i]]+cnt[y[i]]);
            }
        }
        cout<<sol<<'\n';
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 18ms
memory: 3676kb

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
0
19
7
5
2
11
19
5
2
10
6
2
4
19
18
2
21
5
17
6
0
2
4
17
4
2
7
15
6
2
6
5
4
7
3
7
4
1
19
15
2
4
7
14
13
7
6
10
9
7
8
11
16
0
4
12
8
14
2
6
19
21
16
8
20
14
9
12
6
10
6
8
2
17
9
4
5
3
3
5
20
9
13
11
11
5
1
7
2
0
11
6
8
11
7
14
10
9
10
12
7
9
5
3
8
19
10
5
3
5
4
10
2
6
10
16
5
2
19
1
5
8
7
10
4
...

result:

wrong answer 3rd numbers differ - expected: '1', found: '0'