QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#745674#9573. Social Mediaeastcloud#WA 0ms24780kbC++171.8kb2024-11-14 11:02:352024-11-14 11:02:36

Judging History

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

  • [2024-11-14 11:02:36]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:24780kb
  • [2024-11-14 11:02:35]
  • 提交

answer


#include<bits/stdc++.h>

#define ll long long
#define pi pair<int,int>
#define vi vector<int>
#define cpy(x,y,s) memcpy(x,y,sizeof(x[0])*(s))
#define mset(x,v,s) memset(x,v,sizeof(x[0])*(s))
#define all(x) begin(x),end(x)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ary array
#define eb emplace_back
#define IL inline

using namespace std;

#define N 500005

int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9')f=(ch=='-'?-1:f),ch=getchar();
    while(ch>='0' && ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return x*f;
}
void write(int x){
    if(x<0)x=-x,putchar('-');
    if(x/10)write(x/10);
    putchar(x%10+'0');
}

vi e[N];
int a[N],c[N],d[N],buc[N],deg[N];

void solve(){
    int n=read(),m=read(),k=read();
    for(int i=1;i<=k;i++)c[i]=deg[i]=0,e[i].clear();
    for(int i=1;i<=n;i++)a[i]=read(),c[a[i]]++;
    int sum=0,res=0,l=0;
    for(int i=1;i<=m;i++){
        int u=read(),v=read();
        e[u].pb(v);e[v].pb(u);
        sum+=(c[u] && c[v]);
    }
    for(int i=1;i<=k;i++){
        if(!c[i]){
            d[++l]=i;
            for(auto v:e[i])if(c[v] || v==i)deg[i]++;
        }
    }
    sort(d+1,d+l+1,[](int x,int y){return deg[x]>deg[y];});
    if(l<=2){write(m);putchar('\n');return;}
    res=max(res,sum+deg[d[1]]+deg[d[2]]);
    for(int i=1;i<=k;i++){
        if(c[i])continue;
        for(auto v:e[i])if(!c[v])buc[v]++;
        for(auto v:e[i]){
            if(!c[v] && v!=i){
                res=max(res,deg[v]+sum+deg[i]+buc[v]);
            }
        }
        for(auto v:e[i])if(!c[v])buc[v]--;
    }
    write(res);putchar('\n');
}

int main(){
    #ifdef EAST_CLOUD
    freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    #endif

    int T=read();while(T--)solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 24780kb

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:

11
5
1
1
1

result:

wrong answer 1st numbers differ - expected: '9', found: '11'