結果
問題 |
No.2900 Star Divine
|
ユーザー |
![]() |
提出日時 | 2024-09-28 18:40:11 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 46 ms / 2,000 ms |
コード長 | 1,210 bytes |
コンパイル時間 | 5,363 ms |
コンパイル使用メモリ | 280,792 KB |
実行使用メモリ | 13,240 KB |
最終ジャッジ日時 | 2024-09-28 18:40:19 |
合計ジャッジ時間 | 5,115 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
ソースコード
#include <bits/stdc++.h> #define _1 (__int128)1 using namespace std; using ll = long long; void FileIO (const string s) { freopen(string(s + ".in").c_str(), "r", stdin); freopen(string(s + ".out").c_str(), "w", stdout); } const int N = 1e5 + 10; int T, n, m, ed, stk[N], top, stk_[N], top_, ans, lst[N]; set<int> g[N]; bool f[N]; void Solve () { cin >> n >> m >> ed, top = top_ = 0; for (int i = 1; i <= m; i++) g[i] = set<int> (); for (int i = 1; i <= n; i++) f[i] = 0, lst[i] = 0; for (int i = 1, x, y; i <= ed; i++) cin >> x >> y, g[y].insert(x), lst[x] = max(lst[x], y); for (int i = 1; i <= m; i++) { int cnt = 1, cnt_ = 0; for (int j : g[i]) if (i == lst[j]) cnt += !f[j], cnt_ += f[j]; if (cnt > cnt_) { stk[++top] = i; for (int j : g[i]) f[j] ^= 1; } } for (int i = 1; i <= n; i++) if (f[i]) stk_[++top_] = i; cout << top_ << ' ' << top << '\n'; for (int i = 1; i <= top_; i++) cout << stk_[i] << ' '; cout << '\n'; for (int i = 1; i <= top; i++) cout << stk[i] << ' '; } signed main () { ios::sync_with_stdio(0), cin.tie(0); // FileIO(""); for (cin >> T; T--; Solve(), cout << '\n') {} return 0; }