QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#709066#9525. Welcome to Join the Online Meeting!szjWA 103ms74364kbC++112.4kb2024-11-04 11:08:432024-11-04 11:08:44

Judging History

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

  • [2024-11-04 11:08:44]
  • 评测
  • 测评结果:WA
  • 用时:103ms
  • 内存:74364kb
  • [2024-11-04 11:08:43]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define IOS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const long double PI = acos(-1);
const ll mod = 1e9 + 7;
const int maxn = 1e6 + 7;
const ll P = 133331;

ll qgcd(ll a, ll b) {
    return b == 0 ? a : qgcd(b, a % b);
}

ll qpow(ll a, ll b) {
    ll ans = 1;
    while (b) {
        if (b & 1)
            ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans % mod;
}

int n, m, k, x;
set<int> s;
int q[maxn], p[maxn], b[maxn], c[maxn];
vector<int> v[maxn];
bool vis[maxn];
vector<vector<int>> vt;

int find(int x, int a[]) {
	if (a[x] != x) {
		a[x] = find(a[x], a);
	}
	return a[x];
}

void dfs(int cur) {
	vector<int> vv;
	vv.push_back(cur);
	vis[cur] = 1;
	if (s.find(cur) != s.end())
		return;
	for (auto i: v[cur]) {
		if (vis[i])
			continue;
		vv.push_back(i);
		dfs(i);
	}
	if (vv.size() > 1) 
	vt.push_back(vv);
}

void solve() {
	cin >> n >> m >> k;
	for (int i = 1; i <= k; i++) {
		cin >> x;
		s.insert(x);
	}
	for (int i = 1; i <= n; i++) {
		b[i] = i;
		c[i] = i;
	}
	for (int i = 1; i <= m; i++) {
		cin >> q[i] >> p[i];
		v[q[i]].push_back(p[i]);
		v[p[i]].push_back(q[i]);
		if (s.find(q[i]) == s.end() && s.find(p[i]) == s.end()) {
			b[q[i]] = find(p[i], b);
		}
		c[q[i]] = find(p[i], c);
	}
	int flag1 = 1;
	int flag2 = 1;
	int x1 = 0;
	int x2 = find(1, c);
	for (int i = 1; i <= n; i++) {
		if (s.find(i) == s.end()) {
			x1 = find(i, b);
			break;
		}
	}
	for (int i = 1; i <= n; i++) {
		if (s.find(i) == s.end() && x1 != find(i, b)) {
			flag1 = 0;
		}
		if (x2 != find(i, c)) {
			flag2 = 0;
		}
	}
	if (flag1 == 0 || flag2 == 0) {
		cout << "No\n";
		return;
	}
	for (int i = 1; i <= n; i++) {
		if (s.find(i) == s.end()) {
			dfs(i);
			break;
		}
	}
	for (int i = 1; i <= n; i++) {
		if (vis[i] == 0) {
			cout << "No\n";
			return;
		}
	}
	cout << "Yes\n";
	cout << vt.size() << '\n';
	for (int i = vt.size() - 1; i >= 0; i--) {
		cout << vt[i][0] << " " << vt[i].size() - 1 << " ";
		for (int j = 1; j < vt[i].size(); j++) {
			cout << vt[i][j] << " ";
		}
		cout << "\n";
	}
}

int main() {
    IOS;
    int T = 1;
//    cin >> T;
    while (T--) {
        solve();
    }
    return 0;
}

/*


*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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: 4ms
memory: 34944kb

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: 0
Accepted
time: 3ms
memory: 34444kb

input:

6 6 0

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

output:

No

result:

ok ok

Test #5:

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

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 2 95113 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 
1549...

result:

ok ok

Test #6:

score: 0
Accepted
time: 103ms
memory: 74364kb

input:

199999 199998 1
136702
159826 166341
166341 59559
59559 169672
169672 102084
102084 136269
136269 57057
57057 59116
59116 119963
119963 85663
85663 33942
33942 84604
84604 189395
189395 154906
154906 22175
22175 144902
144902 198523
198523 35993
35993 35690
35690 47504
47504 104458
104458 68253
6825...

output:

Yes
199997
1 2 172082 191801 
191801 1 65736 
65736 1 10794 
10794 1 50503 
50503 1 194943 
194943 1 42759 
42759 1 35447 
35447 1 55027 
55027 1 175222 
175222 1 103541 
103541 1 104528 
104528 1 21620 
21620 1 141581 
141581 1 74591 
74591 1 43436 
43436 1 42438 
42438 1 84592 
84592 1 29722 
2972...

result:

ok ok

Test #7:

score: 0
Accepted
time: 95ms
memory: 68152kb

input:

199998 199997 0

67665 130538
130538 101337
101337 73749
73749 138128
138128 1274
1274 108069
108069 50961
50961 7039
7039 109946
109946 170551
170551 193330
193330 113590
113590 92775
92775 2146
2146 43591
43591 125033
125033 75583
75583 173991
173991 46820
46820 3986
3986 163272
163272 91657
91657...

output:

Yes
199996
1 2 5661 102870 
102870 1 182503 
182503 1 106861 
106861 1 147686 
147686 1 106747 
106747 1 182217 
182217 1 124210 
124210 1 72832 
72832 1 107526 
107526 1 187820 
187820 1 28484 
28484 1 57839 
57839 1 78991 
78991 1 150102 
150102 1 184106 
184106 1 64483 
64483 1 135180 
135180 1 4...

result:

ok ok

Test #8:

score: 0
Accepted
time: 40ms
memory: 48244kb

input:

199997 199996 1
158877
35837 79489
79489 72932
72932 14238
14238 73007
73007 66909
66909 49015
49015 129581
129581 138449
138449 94774
94774 189625
189625 23578
23578 31043
31043 146625
146625 161587
161587 136966
136966 184859
184859 27587
27587 155616
155616 72392
72392 195320
195320 75551
75551 1...

output:

No

result:

ok ok

Test #9:

score: 0
Accepted
time: 35ms
memory: 41232kb

input:

200000 199999 1
29111
29111 80079
29111 131587
29111 197066
29111 125194
29111 156736
50697 29111
29111 74382
113595 29111
29111 26046
29111 172868
178564 29111
174875 29111
93471 29111
88216 29111
29111 147893
29111 145746
29111 34038
146500 29111
67862 29111
29111 19222
29111 121535
29111 49102
29...

output:

No

result:

ok ok

Test #10:

score: -100
Wrong Answer
time: 36ms
memory: 47960kb

input:

199999 199998 2
52512 104330
130511 66864
139434 66864
92884 66864
66864 185580
184115 66864
137395 66864
66864 43463
118395 66864
111697 66864
66864 133237
66864 112507
66864 140264
66864 10
66864 151082
155779 66864
107988 66864
148839 66864
66864 40909
172685 66864
66864 189374
180054 66864
49 66...

output:

No

result:

wrong answer jury has found a solution, but participant hasn't