QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#758787#9525. Welcome to Join the Online Meeting!W_Trace2#WA 2ms11804kbC++142.0kb2024-11-17 19:45:222024-11-17 19:45:23

Judging History

你现在查看的是最新测评结果

  • [2024-11-17 19:45:23]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:11804kb
  • [2024-11-17 19:45:22]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
using namespace std;
inline int read(){
	int a=0,b=1;char c=getchar();
	for(;c<'0'||c>'9';c=getchar())if(c=='-')b=-1;
	for(;c>='0'&&c<='9';c=getchar())a=a*10+c-'0';
	return a*b;
}
struct edge
{
    int next,to;
}e[1000001];
int head[1000001],tot,ind[200001];
inline void add(int i,int j)
{
    // cout<<i<<' '<<j<<endl;
    ind[j]++;
    e[++tot].next=head[i];
    e[tot].to=j;
    head[i]=tot;
}
int n,m,k,is_busy[200001];
vector<int> point;
vector<int> ans[200001];
int cnt,vis[200001];
void bfs(int st)
{
    queue<int> q;
    vis[st]=1;
    q.push(st);
    while(!q.empty())
    {
        int x=q.front();
        q.pop();
        point.push_back(x);
        for(int i=head[x];i!=0;i=e[i].next)
        {
            int u=e[i].to;
            if(vis[u])continue;
            vis[u]=1;
            ans[cnt].push_back(u);
            q.push(u);
        }
        cnt++;
    }
}
int main()
{
    n=read(),m=read(),k=read();
    for(int i=1;i<=k;i++)
    {
        is_busy[read()]=1;
    }
    for(int i=1;i<=m;i++)
    {
        int x=read(),y=read();
        if(is_busy[y]==1)
        {
            if(is_busy[x]==0)
                add(x,y);
        }
        else
        if(is_busy[x]==1)
            add(y,x);
        else
        {
            add(y,x);
            add(x,y);
        }
    }
    int st=0;
    for(int i=1;i<=n;i++)
    {
        if(is_busy[i]==0)
        {
            st=i;
            break;
        }
    }
    bfs(st);
    bool flag=0;
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])flag=1;
    }
    if(flag==1)
    {
        cout<<"No"<<'\n';
        return 0;
    }
    cout<<"Yes\n";
    cout<<point.size()<<'\n';
    for(int i=0;i<point.size();i++)
    {
        if(ans[i].size()==0)continue;
        cout<<point[i]<<' '<<ans[i].size()<<' ';
        for(int j=0;j<ans[i].size();j++)
        {
            cout<<ans[i][j]<<' ';
        }
        cout<<'\n';
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 11804kb

input:

4 5 2
3 4
1 2
1 3
2 3
3 4
2 4

output:

Yes
4
1 2 3 2 
2 1 4 

result:

wrong output format Unexpected end of file - int32 expected