QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#729434#9573. Social Mediaucup-team3282#WA 4ms53096kbC++142.3kb2024-11-09 17:06:502024-11-09 17:06:52

Judging History

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

  • [2024-11-09 17:06:52]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:53096kb
  • [2024-11-09 17:06:50]
  • 提交

answer

#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<vector>
using namespace std;
vector<long long>link[2000050];
long long sum[8000050];bool tb[2000050];
void build(int p,int l,int r){
    sum[p]=0;
    if(l==r){
        return;
    }
    int mid=(l+r)>>1;
    build(p<<1,l,(l+r)>>1);
    build(p<<1|1,mid+1,r);
}
void add(long long p,long long l,long long r,long long np,long long op){
    if(l>np||r<np)return;
    if(l==r){
        sum[p]+=op;
        return;
    }long long mid=(l+r)>>1;
    add(p<<1  ,l    ,mid,np,op);
    add(p<<1|1,mid+1,r  ,np,op);
    sum[p]=max(sum[p<<1],sum[p<<1|1]);
    return;
}

int main(){
    long long t;cin>>t;while(t--){
        long long n,m,k;cin>>n>>m>>k;
        for(long long i=1;i<=k;i++){
            link[i].clear();
            tb[i]=0;
        }
        for(long long i=1;i<=n;i++){
            long long p;cin>>p;tb[p]=1;
        }
        long long anser=0;
        long long cnt=0;
        for(long long i=1;i<=m;i++){
            long long f,t;cin>>f>>t;
            link[f].push_back(t);
            link[t].push_back(f);
            if(tb[f]==1&&tb[t]==1){
                cnt++;
            }else{
                if(tb[f]==1){
                    add(1,1,k,t,1);
                }
                if(tb[t]==1){
                    add(1,1,k,f,1);
                }
            }
        }
        anser=cnt;
        for(long long i=1;i<=k;i++){
            if(tb[i])continue;
            long long th=0;
            
            add(1,1,k,i,-1919810);
            long long kk=0;
            for(auto x:link[i]){
                if(x==i){
                    kk++;
                }else
                    if(tb[x]){
                    th++;
                }else{
                    add(1,1,k,x,1);
                }
            }
            th+=kk/2;
            if(kk%2==1){
                while(1);
            }
            // cout<<sum[1]<<"!";
            anser=max(anser,cnt+th+sum[1]);
            for(auto x:link[i]){
                if(tb[x]||x==i){
                    th++;
                }else{
                    add(1,1,k,x,-1);
                }
            }
            // add(1,1,k,i,1919810);
        }
        cout<<anser<<endl;
    }

}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 4ms
memory: 53096kb

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
0
1
1

result:

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