QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#805361 | #9573. Social Media | victoryAC# | WA | 28ms | 74916kb | C++14 | 1.4kb | 2024-12-08 16:10:48 | 2024-12-08 16:10:49 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> PII;
#define endl '\n'
const int N=1e6+10;
const int mod=1e9+7;
const double eps=1e-9;
ll f[N];
vector<ll> e[N];
vector<ll> x[N];
vector<ll> g[N];
void solve()
{
ll n,m,k;
cin>>n>>m>>k;
map<ll,ll> mp;
for(int i=1;i<=n;i++)
{
cin>>f[i];
mp[f[i]]++;
}
ll ans=0,mx=0;
for(int i=1;i<=m;i++)
{
ll u,v;
cin>>u>>v;
if(mp.count(u)&&mp.count(v)) ans++;
else if(mp.count(u)) e[v].push_back(u);
else if(mp.count(v)) x[v].push_back(u);
else if(!mp.count(u)&&!mp.count(v))
{
g[v].push_back(u);
mx=max(mx,(ll)g[v].size()+(ll)g[u].size());
}
}
vector<PII> v;
for(int i=1;i<=k;i++)
{
v.push_back({e[i].size(),i});
}
sort(v.begin(),v.end(),greater<PII>());
ll id1=v[0].second,id2=v[1].second;
ll sum1=0,sum2=0;
for(int i=1;i<=n;i++)
{
for(auto j:x[f[i]])
{
if(j==id1) sum1++;
if(j==id2) sum1++;
}
}
for(auto j:g[id1])
{
if(j==id2) sum2++;
}
for(auto j:g[id2])
{
if(j==id1) sum2++;
}
ll sum=sum1+sum2;
cout<<max(ans+sum+v[0].first+v[1].first,ans+sum1+mx)<<endl;
for(int i=1;i<=k;i++) e[i].clear(),g[i].clear(),x[i].clear();
return;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int _=1;
cin>>_;
while(_--)
{
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 4ms
memory: 74916kb
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: 28ms
memory: 74396kb
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 11 1 19 5 3 2 11 19 3 3 9 5 2 4 19 15 4 13 5 17 4 2 2 6 17 3 2 5 15 6 4 4 3 4 6 3 7 4 1 15 15 3 4 5 12 11 7 5 6 6 7 8 11 16 1 4 9 8 14 2 6 19 18 16 7 20 14 8 12 6 9 6 8 2 16 9 5 5 3 8 11 20 7 11 11 10 5 5 7 4 1 8 5 8 11 7 14 9 9 9 11 7 7 5 1 6 14 10 4 3 4 7 9 1 5 8 16 5 2 19 1 3 8 9 10 4 3 1 15 1...
result:
wrong answer 2nd numbers differ - expected: '14', found: '11'