結果
| 問題 | No.2900 Star Divine |
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2024-09-25 20:38:19 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 44 ms / 2,000 ms |
| コード長 | 1,204 bytes |
| コンパイル時間 | 2,060 ms |
| コンパイル使用メモリ | 201,784 KB |
| 最終ジャッジ日時 | 2025-02-24 12:30:13 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
mt19937_64 rnd(time(0));
int x, y, m, u, v, now, cnt, a[N], b[N], T;
set<int>g[N];
void S(){
cin >> x >> y >> m;
for(int i = 1; i <= x; ++i){
g[i].clear();
}
for(int i = 1; i <= m; i++){
cin >> u >> v;
g[u].insert(v);
}
for(int i = 1; i <= 20; ++i){
cnt = 0;
for(int j = 1; j <= y; ++j){
a[j] = rnd() % 2;
cnt += a[j];
}
for(int j = 1; j <= x; ++j){
now = 0;
for(auto v : g[j]){
if(a[v]){
now++;
}
}
b[j] = now % 2;
cnt += b[j];
}
if(cnt >= (x + y + 1) / 2){
vector<int>e1, e2;
for(int j = 1; j <= x; ++j){
if(b[j]){
e1.push_back(j);
}
}
for(int j = 1; j <= y; ++j){
if(a[j]){
e2.push_back(j);
}
}
cout << e1.size() << ' ' << e2.size() << '\n';
for(auto v : e1){
cout << v << ' ';
}
cout << '\n';
for(auto v : e2){
cout << v << ' ';
}
cout << "\n\n";
return ;
}
}
}
int main(){
ios::sync_with_stdio(0), cin.tie(0);
for(cin >> T; T--; S()){
}
return 0;
}
vjudge1