QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#706496 | #9525. Welcome to Join the Online Meeting! | 2366503423 | WA | 836ms | 80524kb | C++14 | 1.5kb | 2024-11-03 11:44:12 | 2024-11-03 11:44:16 |
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;
zhu=cnt[cnt.size()-1];
if(n==200000)cout<<zhu<<'\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: 3580kb
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: 3592kb
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: 3780kb
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: 3608kb
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: 836ms
memory: 80524kb
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:
2 Yes 199997 2 1 198122 198122 1 174755 174755 1 78157 78157 1 175329 175329 1 62691 62691 1 115217 115217 1 188340 188340 1 129441 129441 1 125872 125872 1 188218 188218 1 160138 160138 1 113423 113423 1 161467 161467 1 126302 126302 1 143262 143262 1 40139 40139 1 116789 116789 1 172464 172464 1 7...
result:
wrong answer Token parameter [name=pans] equals to "2", doesn't correspond to pattern "Yes|No"