結果
| 問題 |
No.2900 Star Divine
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2024-09-25 21:41:14 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,296 bytes |
| コンパイル時間 | 2,042 ms |
| コンパイル使用メモリ | 198,688 KB |
| 最終ジャッジ日時 | 2025-02-24 12:35:17 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 TLE * 1 -- * 8 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int T, x, y, m;
bool f[N], vis[N];
vector<int> g[N];
mt19937 rnd(time(0));
void Solve() {
cin >> x >> y >> m;
while (m--) {
int u, v; cin >> u >> v;
g[u].push_back(v);
}
while (1) {
int ct = 0;
for (int i = 1; i <= y; i++) {
f[i] = rnd() % 2, ct += f[i];
}
for (int i = 1; i <= x; i++) {
int cnt = 0;
for (int j : g[i]) cnt += f[j];
if (cnt % 2) ct++, vis[i] = 1;
}
if (ct >= (x + y + 1) / 2) {
vector<int> p, q;
for (int i = 1; i <= x; i++) {
if (vis[i]) p.push_back(i);
}
for (int i = 1; i <= y; i++) {
if (f[i]) q.push_back(i);
}
cout << p.size() << ' ' << q.size() << '\n';
for (int x : p) cout << x << ' ';
cout << '\n';
for (int x : q) cout << x << ' ';
cout << '\n';
break;
}
fill(vis + 1, vis + x + 1, 0);
}
for (int i = 1; i <= x; i++) g[i].clear(), vis[i] = 0;
cout << '\n';
}
int main() {
ios::sync_with_stdio(0), cin.tie(0);
cin >> T;
while (T--) Solve();
return 0;
}
///
vjudge1