結果

問題 No.2900 Star Divine
ユーザー vjudge1
提出日時 2024-09-25 20:35:23
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,202 bytes
コンパイル時間 2,041 ms
コンパイル使用メモリ 202,540 KB
最終ジャッジ日時 2025-02-24 12:29:54
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#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 <= 10; ++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(a[j]){
          e1.push_back(j);
        }
      }
      for(int j = 1; j <= y; ++j){
        if(b[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';
      return ;
    }
  }
}

int main(){
  ios::sync_with_stdio(0), cin.tie(0);
  for(cin >> T; T--; S()){
  }
  return 0;
}
0