結果
問題 |
No.2900 Star Divine
|
ユーザー |
![]() |
提出日時 | 2024-09-25 21:36:29 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,267 bytes |
コンパイル時間 | 2,277 ms |
コンパイル使用メモリ | 198,508 KB |
最終ジャッジ日時 | 2025-02-24 12:35:06 |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | WA * 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(); } int main() { ios::sync_with_stdio(0), cin.tie(0); cin >> T; while (T--) Solve(); return 0; } ////