QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#708856#9525. Welcome to Join the Online Meeting!qzez#WA 3ms14380kbC++141.3kb2024-11-04 08:48:002024-11-04 08:48:02

Judging History

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

  • [2024-11-04 08:48:02]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:14380kb
  • [2024-11-04 08:48:00]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int maxn=200005;
int read(){
    int ret=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
    while( isdigit(ch)){ret=(ret<<3)+(ret<<1)+(ch&15);ch=getchar();}
    return ret*f;
}
int n,m,k,s,tot; 
vector<int> G[maxn],son[maxn];
int dfn[maxn],id[maxn];
bool dwn[maxn],vis[maxn];
void DFS(int now){
    vis[now]=1;
    if(dwn[now]) return ;
    dfn[now]=++tot;
    id[tot]=now;
    for(auto s:G[now]){
        if(vis[s]) continue;
        DFS(s);
        son[now].push_back(s);
    }
}
int main(){
    n=read(),m=read(),k=read();
    for(int i=1;i<=k;++i){
        dwn[read()]=1;
    }
    for(int i=1;i<=m;++i){
        int u=read(),v=read();
        G[u].push_back(v);
        G[v].push_back(u);
    }
    for(int i=1;i<=n;++i){
        if(!dwn[i]){
            s=i;
            break;
        }
    }
    DFS(s);
    for(int i=1;i<=n;++i){
        if(!vis[i]){
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n%d\n",tot);
    for(int i=1;i<=tot;++i){
        int now=id[i];
        printf("%d ",now);
        printf("%d ",son[now].size());
        for(auto s:son[now]) printf("%d ",s);
        printf("\n");
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 3ms
memory: 14276kb

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: 13172kb

input:

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

output:

Yes
2
1 3 3 4 2 
2 0 

result:

wrong answer Integer parameter [name=y_j] equals to 0, violates the range [1, 4]