QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#760926 | #9525. Welcome to Join the Online Meeting! | Hanoist | WA | 3ms | 10752kb | C++14 | 2.4kb | 2024-11-18 20:13:10 | 2024-11-18 20:13:10 |
Judging History
answer
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<functional>
#include<utility>
#include<cassert>
using namespace std;
inline long long read(){
long long x = 0,f = 1;
char c = getchar();
while(c < '0' || c > '9'){
if(c == '-') f = -1;
c = getchar();
}
while(c >= '0' && c <= '9'){
x = (x << 3) + (x << 1) + (c ^ 48);
c = getchar();
}
return x * f;
}
const int N = 2e5 + 11;
const int M = 5e5 + 11;
int n,m,k,cnt,tt,head[N],ecnt = -1,id[N];
bool flag[N],vis[N];
vector<int> v[N];
queue<int> Q;
struct yjx{
int nxt,to;
}e[M << 1];
inline void save(int x,int y){
e[++ecnt] = (yjx){head[x],y};
head[x] = ecnt;
}
void dfs(int now){
int i,temp;
//if(vis[now]) return;
++cnt;
vis[now] = 1;
for(i = head[now];~i;i = e[i].nxt){
temp = e[i].to;
if(vis[temp]) continue;
else if(flag[temp]) ++cnt,vis[temp] = 1;
else dfs(temp);
}
}
void bfs(int s){
int i,now,temp;
Q.push(s);
while(!Q.empty()){
now = Q.front();
Q.pop();
if(vis[now]) continue;
vis[now] = 1;
id[++tt] = now;
for(i = head[now];~i;i = e[i].nxt){
temp = e[i].to;
if(vis[temp]) continue;
vis[temp] = 1;
v[tt].push_back(temp);
if(!flag[temp]) Q.push(temp);
}
}
}
int main(){
int t,i,j,k,x,y,s;
memset(head,-1,sizeof(head));
n = read(),m = read(),k = read();
for(i = 1;i <= k;i++){
x = read();
flag[x] = 1;
}
for(i = 1;i <= m;i++){
x = read(),y = read();
save(x,y),save(y,x);
}
for(i = 1;i <= n;i++){
if(!flag[i]){
s = i;
dfs(s);
break;
}
}
if(cnt != n){
puts("No");
return 0;
}
puts("Yes");
for(i = 1;i <= n;i++) vis[i] = 0;
bfs(s);
int res = 0;
for(i = 1;i <= tt;i++){
if(v[i].size() > 0) ++res;
}
printf("%d\n",res);
for(i = 1;i <= tt;i++){
if(!v[i].size()) continue;
printf("%d %d ",id[i],(int)v[i].size());
for(j = 0;j < (int)v[i].size();j++){
printf("%d ",v[i][j]);
}
puts("");
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 3ms
memory: 10752kb
input:
4 5 2 3 4 1 2 1 3 2 3 3 4 2 4
output:
Yes 1 1 2 3 2
result:
wrong answer member 4 is not invited