QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#729434 | #9573. Social Media | ucup-team3282# | WA | 4ms | 53096kb | C++14 | 2.3kb | 2024-11-09 17:06:50 | 2024-11-09 17:06:52 |
Judging History
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;
}
}
Details
Tip: Click on the bar to expand more detailed information
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'