QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#714899 | #9525. Welcome to Join the Online Meeting! | ucup-team4717# | RE | 1ms | 8200kb | C++20 | 1.5kb | 2024-11-06 09:04:26 | 2024-11-06 09:04:26 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define N 100005
using namespace std;
int T;
int n,m,k;
int a[N];
int x[N],t[N];
int vis[N],viss[N];
int cnt;
vector<int> g[N],f[N],e;
void bfs(int s){
queue<int> q;
q.push(s);
cnt=0;
viss[s]=1;
e.push_back(s);
while(!q.empty()){
int x=q.front();
q.pop();if(vis[x]) continue;
for(int i:g[x]){
if(viss[i]) continue;
f[x].push_back(i);
viss[i]=++cnt;
e.push_back(i);
q.push(i);
}
}
}
void sol(){
for(int i=1;i<=n;i++) g[i].clear(),f[i].clear(),vis[i]=viss[i]=0;
e.clear();
scanf("%lld %lld %lld",&n,&m,&k);
for(int i=1,x;i<=k;i++){
scanf("%lld",&x);
vis[x]=1;
}
for(int i=1,u,v;i<=m;i++){
scanf("%lld %lld",&u,&v);
g[u].push_back(v);
g[v].push_back(u);
}
for(int i=1;i<=n;i++){
if(!vis[i]){
bfs(i);
break;
}
}
int s=0;
for(int i=1;i<=n;i++){
if(!viss[i]){
printf("No\n");
return;
}
if(f[i].size()) s++;
}
printf("Yes\n");
printf("%lld\n",s);
for(int i:e){
if(!f[i].size()) continue;
printf("%lld %lld ",i,(int)f[i].size());
for(int j:f[i]) printf("%lld ",j);
printf("\n");
}
}
signed main(){
// scanf("%lld",&T);
T=1;
while(T--) sol();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 5932kb
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: 1ms
memory: 5804kb
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: 8200kb
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: 0ms
memory: 3836kb
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
Runtime Error
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...