QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#761368#9525. Welcome to Join the Online Meeting!YaeMik0WA 0ms18048kbC++231.8kb2024-11-18 22:25:562024-11-18 22:25:57

Judging History

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

  • [2024-11-18 22:25:57]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:18048kb
  • [2024-11-18 22:25:56]
  • 提交

answer

#include<bits/stdc++.h>
#define INF 2147483647LL
#define int long long
#define MAXN 500005
#define mod 1000000007
#define PI 3.14
#define eps 1e-10
#define pa pair<int,int>
#define ms(a,x) memset(a,x,sizeof(a))
#define mc(ar1,ar2) memcpy(ar1,ar2,sizeof(ar2))
#define mkp(a,b) make_pair(a,b)
#define ls (p<<1)
#define rs (p<<1|1)
#define fn(i,st,ed) for(int i=st;i<=ed;++i)
#define fd(i,st,ed) for(int i=st;i>=ed;--i)
#define fg(i,x,head,e) for(int i=head[x];~i;i=e[i].nxt)
using namespace std;
inline int read(){int x=0,f=1;char c=getchar();while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}while(isdigit(c)){x=x*10+c-'0';c=getchar();}return x*f;}
struct edge{int to,nxt;}e[MAXN];
int head[MAXN],ecnt=-1,ans=0;
inline void insert(int x,int y){e[++ecnt]={y,head[x]};head[x]=ecnt;}
int bs[MAXN],ansx[MAXN],anscnt[MAXN],vis[MAXN];
vector<int>ansv[MAXN];
void dfs(int x){
    vis[x]=1;
    if(head[x]==-1||bs[x])return;
    ansx[++ans]=x;
    fg(i,x,head,e){
        int to=e[i].to;
        if(vis[to])continue;
        ansv[ans].push_back(to);
        anscnt[ans]++;
    }
    fg(i,x,head,e){
        int to=e[i].to;
        if(vis[to])continue;
        dfs(to);
    }
}
void solve(){
    ms(head,-1);
    int n,m,k;cin>>n>>m>>k;
    fn(i,1,k){
        int x;cin>>x;
        bs[x]=1;
    }
    fn(i,1,m){
        int x,y;cin>>x>>y;
        insert(x,y);insert(y,x);
    }
    fn(i,1,n)if(!bs[i]){dfs(i);break;}
    fn(i,1,n)if(!vis[i]){cout<<"No\n";return;}
    cout<<"Yes\n"<<ans<<'\n';
    fn(i,1,ans){
        cout<<ansx[i]<<' '<<anscnt[i]<<' ';
        for(auto x:ansv[i])cout<<x<<' ';
        cout<<'\n';
    }
}
signed main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int T=1;
    while(T--){solve();}
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 17936kb

input:

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

output:

Yes
2
1 2 3 2 
2 1 4 

result:

ok ok

Test #2:

score: 0
Accepted
time: 0ms
memory: 18040kb

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: -100
Wrong Answer
time: 0ms
memory: 18048kb

input:

4 6 2
3 4
1 3
1 4
2 3
2 4
1 2
3 4

output:

Yes
2
1 3 2 4 3 
2 2 4 3 

result:

wrong answer on step #2, member 4 has been invited