QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#706508 | #9525. Welcome to Join the Online Meeting! | 2366503423 | WA | 858ms | 80592kb | C++14 | 1.6kb | 2024-11-03 11:51:26 | 2024-11-03 11:51:27 |
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;}
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;
}
}
//cout<<zhu<<" "<<cnt[3]<<'\n';
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: 100
Accepted
time: 0ms
memory: 3596kb
input:
4 5 2 3 4 1 2 1 3 2 3 3 4 2 4
output:
Yes 2 1 2 2 3 2 1 4
result:
ok ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
4 5 3 2 4 3 1 2 1 3 2 3 3 4 2 4
output:
No
result:
ok ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
4 6 2 3 4 1 3 1 4 2 3 2 4 1 2 3 4
output:
Yes 1 1 3 2 3 4
result:
ok ok
Test #4:
score: 0
Accepted
time: 0ms
memory: 3472kb
input:
6 6 0 1 2 2 3 3 1 4 5 5 6 6 4
output:
No
result:
ok ok
Test #5:
score: -100
Wrong Answer
time: 858ms
memory: 80592kb
input:
200000 199999 2 142330 49798 49798 116486 116486 64386 64386 192793 192793 61212 61212 138489 138489 83788 83788 89573 89573 8596 8596 156548 156548 41800 41800 14478 14478 27908 27908 82806 82806 9353 9353 160166 160166 92308 92308 36265 36265 126943 126943 190578 190578 191148 191148 177381 177381...
output:
Yes 199997 1 1 178679 178679 1 186222 186222 1 122914 122914 1 18533 18533 1 66240 66240 1 143831 143831 1 52965 52965 1 45501 45501 1 36293 36293 1 95051 95051 1 114707 114707 1 90623 90623 1 10911 10911 1 1942 1942 1 41382 41382 1 188734 188734 1 107093 107093 1 154956 154956 1 85071 85071 1 13963...
result:
wrong output format Unexpected end of file - int32 expected