QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#718320#9525. Welcome to Join the Online Meeting!teaWA 7ms51912kbC++143.0kb2024-11-06 20:15:452024-11-06 20:15:46

Judging History

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

  • [2024-11-06 20:15:46]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:51912kb
  • [2024-11-06 20:15:45]
  • 提交

answer

// #pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
#define IOS                      \
    ios::sync_with_stdio(false); \
    cin.tie(0);                  \
    cout.tie(0);
#define pb push_back
#define st first
#define nd second
#define PII pair<ll, ll>
#define D(x, y) cout << x << "=" << y << endl;
#define fcout(x, n) cout << fixed << setprecision(x) << n << endl;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define rep2(i, a, b) for (int i = a; i >= b; i--)
// #define int long long
// #define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
const ll inf = 0x3f3f3f3f;
const int N = 1e6 + 10;
const int M = 1e9+7;
inline ll read()
{
    ll x = 0;
    bool f = 1;
    char c = getchar();
    for (; !isdigit(c); c = getchar())
        if (c == '-')
            f = 0;
    for (; isdigit(c); c = getchar())
        x = (x << 3) + (x << 1) + c - '0';
    return f ? x : 0 - x;
}
inline void out(ll x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        out(x / 10);
    putchar(x % 10 + '0');
}
// __int128 rd()
// {
// 	char arr[30];
// 	__int128 res = 0;
// 	scanf("%s", arr);
// 	for (int i = 1; i <= strlen(arr); i++)
// 	{
// 		res *= 10;
// 		res += arr[i]-'0';
// 	}
// 	return res;
// }
// void pt(__int128 num)
// {
// 	if (num > 9) pt(num / 10);
// 	putchar(num % 10 + '0');
// }

ll n, m;
bool yy[N]={0};
bool vis[N]={0};
vector< vector<ll> >v(N),ans(N);
ll sum[N];
queue<ll>q;
ll bfs(ll x,ll l)
{
    while(!q.empty())
    {
        ll t=q.front();
        q.pop();
        ans[l].pb(t);
        for(auto i:v[t])
        {
            if(!vis[i])
            {
                if(!yy[i]) q.push(i);
                vis[i]=1;
                ans[l].pb(i);
                sum[l]++;
            }
        }
        if(sum[l]!=0) l++;
    }
    return l;
}
void solve()
{
    ll k;
    cin>>n>>m>>k;
    rep(i,0,k)
    {
        ll t;cin>>t;
        yy[t]=1;
    }
    rep(i,0,m)
    {
        ll x,y;cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
    }
    rep(i,1,n+1)
    {
        if(yy[i])
        {
            bool b=0;
            for(auto j:v[i])
            {
                if(!yy[j]) 
                {
                    b=1;
                    break;
                }
            }
            if(!b) return cout<<"No\n",void();
        }
    }
    cout<<"Yes\n";
    ll l;
    rep(i,1,n+1)
    {
        if(!yy[i])
        {
            q.push(i);vis[i]=1;
            l=bfs(i,0);
            break;
        }
    }
    cout<<l<<endl;
    rep(i,0,l)
    {
        cout<<*ans[i].begin()<<" "<<sum[i]<<" ";
        auto it=ans[i].begin()+1;
        for(;it!=ans[i].end();it++)
        {
            cout<<*it<<" ";
        }
        cout<<endl;
    }
}
signed main()
{
    IOS
        // freopen("../.vscode/io/in.txt","r",stdin),freopen("../.vscode/io/out.txt","w",stdout);
        ll T = 1;
    // cin >> T;
    while (T--)
        solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 7ms
memory: 51864kb

input:

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

output:

Yes
2
1 2 2 3 
2 1 4 

result:

ok ok

Test #2:

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

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: 6ms
memory: 51912kb

input:

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

output:

Yes
1
1 3 3 4 2 

result:

ok ok

Test #4:

score: -100
Wrong Answer
time: 4ms
memory: 51724kb

input:

6 6 0

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

output:

Yes
1
1 2 2 3 

result:

wrong answer member 4 is not invited