QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#706500 | #9525. Welcome to Join the Online Meeting! | 2366503423 | WA | 0ms | 3540kb | C++14 | 1.6kb | 2024-11-03 11:46:31 | 2024-11-03 11:46:31 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
map <int,int> cha;
int find(int x)
{
if(cha[x]==x) return x;
return cha[x]=find(cha[x]);
}
int main()
{
int n,m,k;cin>>n>>m>>k;
map <int,bool> book;
vector <pair<int,int>> a,b;
for(int i=1;i<=n;i++) cha[i]=i;
while(k--)
{
int x;cin>>x;
book[x]=1;
}
vector <int> cnt(n+1,0);
while(m--)
{
int x,y;cin>>x>>y;
a.push_back({x,y});
if(book[x]!=1&&book[y]!=1) {cha[find(x)]=find(y);cnt[x]++;cnt[y]++;}
else{b.push_back({x,y});}
}
for(int i=0;i<b.size();i++)
{
int x=b[i].first,y=b[i].second;
if(book[x]==1&&book[y]!=1) cha[x]=find(y);
if(book[y]==1&&book[x]!=1) cha[y]=find(x);
}
int zhu=cha.begin()->second;
bool f=1;
for(auto &i:cha)
{
if(zhu!=i.second){f=0;break;}
}
if(f==0){cout<<"No";return 0;}
sort(cnt.begin(),cnt.end());
map <int,set<int>> ans;
map <int,bool> la;
int mx=0;
for(int i=1;i<cnt.size();i++)
{
if(mx<cnt[i])
{
mx=cnt[i];
zhu=i;
}
}
la[zhu]=1;
for(int i=0;i<a.size();i++)
{
int x=a[i].first,y=a[i].second;
if(book[x]!=1)
{
if(la[y]!=1)
{
ans[x].insert(y);
la[y]=1;
}
}
if(book[y]!=1)
{
if(la[x]!=1)
{
ans[y].insert(x);
la[x]=1;
}
}
}
cout<<"Yes"<<'\n';
cout<<ans.size()<<'\n';
queue <int> dui;
dui.push(zhu);
while(dui.size()>0)
{
int y=dui.front();
dui.pop();
cout<<y<<' '<<ans[y].size();
for(auto &j:ans.find(y)->second)
{
cout<<' '<<j;
if(ans.find(j)!=ans.end()) dui.push(j);
}
cout<<'\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3540kb
input:
4 5 2 3 4 1 2 1 3 2 3 3 4 2 4
output:
Yes 2 3 0
result:
wrong answer on step #1, member 3 invited others when being banned