QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#769314 | #9525. Welcome to Join the Online Meeting! | kirco | WA | 242ms | 48612kb | C++23 | 1.3kb | 2024-11-21 17:05:25 | 2024-11-21 17:05:26 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define iosy ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
const int N = 2e5+10;
const int maxn = 5e5+5;
vector<int> e[N<<1];
map<int,vector<int>> mp;
bool use[N],a[N];
int n,m,k;
void dfs(int u,int fa){
use[u]=1;
for(auto& v:e[u]){
if(v==fa)continue;
if(!use[v]){
use[v]=1;
mp[u].push_back(v);
if(!a[v])dfs(v,u);
}
}
}
void solve(){
cin>>n>>m>>k;
for(int i=1;i<=k;i++){
int busy;cin>>busy;
a[busy]=1;
}
for(int i=1;i<=m;i++){
int u,v;cin>>u>>v;
e[u].push_back(v);
e[v].push_back(u);
}
int start=-1;//从非k开始
for(int i=1;i<=n;i++){
if(!a[i]){
start=i;
break;
}
}
dfs(start,-1);
//bfs
// queue<int> q;q.push(start);
// use[start]=1;
// while(!q.empty()){
// int u=q.front();q.pop();
// for(auto& v:e[u]){
// if(!use[v]){
// use[v]=1;
// mp[u].push_back(v);
// if(!a[v])q.push(v);
// }
// }
// }
for(int i=1;i<=n;i++){
if(!use[i]){
cout<<"No\n";
return;
}
}
cout<<"Yes\n";
cout<<mp.size()<<"\n";
for(auto& [x,y]:mp){
cout<<x<<" "<<y.size()<<" ";
for(int i=0;i<y.size();i++){
cout<<y[i]<<" ";
}
cout<<"\n";
}
}
signed main()
{
iosy;int _t=1;
// cin>>_t;
while(_t--){solve();}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 5648kb
input:
4 5 2 3 4 1 2 1 3 2 3 3 4 2 4
output:
Yes 2 1 1 2 2 2 3 4
result:
ok ok
Test #2:
score: 0
Accepted
time: 1ms
memory: 3732kb
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: 1ms
memory: 3720kb
input:
4 6 2 3 4 1 3 1 4 2 3 2 4 1 2 3 4
output:
Yes 1 1 3 3 4 2
result:
ok ok
Test #4:
score: 0
Accepted
time: 1ms
memory: 3740kb
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: 242ms
memory: 48612kb
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 199998 1 2 95113 178679 2 1 198122 3 1 41738 4 1 196324 5 1 91673 6 1 796 7 1 136018 8 1 100182 9 1 101606 10 1 73864 11 1 105951 12 1 63827 13 1 130553 14 1 177897 15 1 196567 16 1 92389 17 1 72182 18 1 141202 19 1 45379 20 1 114057 21 1 105287 22 1 7260 23 1 40268 24 1 5...
result:
wrong answer on step #2, member 2 is not invited before inviting others