QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#787772 | #9573. Social Media | SZH# | WA | 9ms | 5684kb | C++14 | 1.9kb | 2024-11-27 14:33:18 | 2024-11-27 14:33:19 |
Judging History
answer
#include<bits/stdc++.h>
#define pa pair<int,int>
#define INF 0x3f3f3f3f
#define inf 0x3f
#define fi first
#define se second
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define pb push_back
using namespace std;
inline ll read()
{
ll f=1,sum=0;char c=getchar();
while (!isdigit(c)) {if (c=='-') f=-1;c=getchar();}
while (isdigit(c)) {sum=sum*10+c-'0';c=getchar();}
return sum*f;
}
const int MAXN=200010;
pa es[MAXN];
bool vis[MAXN];
int num[MAXN];
map <pa,int> show;
int main()
{
int T=read();
while (T--)
{
int n=read(),m=read(),k=read();
for (int i=1;i<=n;i++) vis[read()]=1;
int pre=0;
for (int i=1;i<=m;i++)
{
int u=read(),v=read();
es[i]=mp(u,v);
if (vis[u] && vis[v]) pre++;
else if (vis[u]) num[v]++;
else if (vis[v]) num[u]++;
else if (u==v) num[u]++;
else show[mp(min(u,v),max(u,v))]++;
}
int mx=0,mxid,sec=0,secid;
for (int i=1;i<=k;i++)
{
if (vis[i]) continue;
if (num[i]>mx) mx=num[i],mxid=i;
else if (num[i]>sec) sec=num[i],secid=i;
}
// cout<<pre<<endl;
int ans=0;
for (int i=1;i<=m;i++)
{
if (vis[es[i].fi] && vis[es[i].se]) continue;
int now=0;
if (vis[es[i].fi]) {
now+=num[es[i].se];
int choose;
if (es[i].se!=mxid) choose=mxid,now+=mx;
else choose=secid,now+=sec;
}
else if (vis[es[i].se])
{
now+=num[es[i].fi];
int choose;
if (es[i].fi!=mxid) choose=mxid,now+=mx;
else choose=secid,now+=sec;
}
else
{
now+=show[mp(min(es[i].fi,es[i].se),max(es[i].fi,es[i].se))];
// cout<<i<<':'<<now;
now+=num[es[i].fi];
if (es[i].fi!=es[i].se) now+=num[es[i].se];
// cout<<' '<<now<<endl;
}
ans=max(ans,now);
// cout<<i<<' '<<now<<endl;
}
cout<<ans+pre<<'\n';
for (int i=1;i<=k;i++) vis[i]=num[i]=0;
show.clear();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3700kb
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: 9ms
memory: 5684kb
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 1 19 6 5 1 11 19 4 3 10 4 1 4 19 15 2 18 4 17 5 1 2 5 17 3 2 6 15 6 3 6 4 4 7 3 7 4 1 16 15 2 3 6 12 12 7 6 8 8 6 8 11 16 1 4 9 8 14 2 6 19 19 16 8 20 14 8 12 7 9 6 8 2 17 9 5 5 3 6 6 20 8 13 11 10 5 3 6 3 1 8 5 8 11 7 14 10 9 9 11 7 9 5 2 8 14 10 5 3 5 5 10 1 6 9 16 5 3 19 1 4 8 8 10 4 2 1 15...
result:
wrong answer 901st numbers differ - expected: '12', found: '11'