QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#760895#9525. Welcome to Join the Online Meeting!HanoistWA 35ms32324kbC++142.1kb2024-11-18 20:01:322024-11-18 20:01:32

Judging History

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

  • [2024-11-18 20:01:32]
  • 评测
  • 测评结果:WA
  • 用时:35ms
  • 内存:32324kb
  • [2024-11-18 20:01:32]
  • 提交

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,head[N],id[N],tt,ecnt = -1;
bool flag[N],vis[N];
vector<int> v[N];
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 dfss(int now){
    int i,temp;
    bool o = 0;
    if(vis[now]) return;
    vis[now] = 1;
    for(i = head[now];~i;i = e[i].nxt){
        temp = e[i].to;
        if(vis[temp]) continue;
        if(!o) id[++tt] = now,o = 1;
        v[tt].push_back(temp);
        if(flag[temp]) vis[temp] = 1;
        else dfss(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;
    dfss(s);
    printf("%d\n",tt);
    for(i = 1;i <= tt;i++){
        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: 100
Accepted
time: 3ms
memory: 10632kb

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: 2ms
memory: 10492kb

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

input:

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

output:

Yes
2
1 1 2 
2 2 4 3 

result:

ok ok

Test #4:

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

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
Wrong Answer
time: 35ms
memory: 32324kb

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...

output:

Yes
199998
1 1 178679 
178679 1 186222 
186222 1 122914 
122914 1 18533 
18533 1 66240 
66240 1 143831 
143831 1 52965 
52965 1 45501 
45501 1 36293 
36293 1 95051 
95051 1 114707 
114707 1 90623 
90623 1 10911 
10911 1 1942 
1942 1 41382 
41382 1 188734 
188734 1 107093 
107093 1 154956 
154956 1 8...

result:

wrong answer on step #126763, member 95113 is not friend of 186051