結果

問題 No.1582 Vertexes vs Edges
コンテスト
ユーザー 👑 Nachia
提出日時 2021-07-02 21:24:31
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 596 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 593 ms
コンパイル使用メモリ 100,840 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2026-06-21 08:54:36
合計ジャッジ時間 3,301 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 3 WA * 33
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
#include <atcoder/dsu>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

int N;

int main(){
  cin >> N;
  atcoder::dsu G(2*N);
  rep(i,N-1){
    int u,v; cin >> u >> v; u--; v--;
    G.merge(u,v+N);
    G.merge(u+N,v);
  }
  auto GG = G.groups();
  int C[2] = {};
  for(int i : GG[0]) C[i/N]++;
  int ans = min(C[0],C[1]);
  cout << ans << "\n";
  return 0;
}

struct ios_do_not_sync{
  ios_do_not_sync(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
  }
} ios_do_not_sync_inst;
0