結果
| 問題 | No.1582 Vertexes vs Edges |
| コンテスト | |
| ユーザー |
Nachia
|
| 提出日時 | 2021-07-02 21:24:31 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 596 bytes |
| 記録 | |
| コンパイル時間 | 1,173 ms |
| コンパイル使用メモリ | 83,660 KB |
| 最終ジャッジ日時 | 2025-01-22 15:37:51 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 3 WA * 33 |
ソースコード
#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;
Nachia