結果
問題 |
No.3024 全単射的
|
ユーザー |
![]() |
提出日時 | 2025-02-15 03:03:06 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 814 bytes |
コンパイル時間 | 3,879 ms |
コンパイル使用メモリ | 297,684 KB |
実行使用メモリ | 31,644 KB |
最終ジャッジ日時 | 2025-02-15 03:03:14 |
合計ジャッジ時間 | 7,437 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 RE * 4 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; const int INF = 1e9 + 10; const ll INFL = 4e18; #include <atcoder/maxflow> int main() { ll N, M; cin >> N >> M; vector<ll> X(N), Y(N), V; for (int i = 0; i < N; i++) cin >> X[i] >> Y[i], V.push_back(X[i]), V.push_back(Y[i]); ranges::sort(V); V.erase(unique(V.begin(), V.end()), V.end()); auto get = [&](ll x) { return ranges::lower_bound(V, x) - V.begin(); }; int S = ssize(V); int T = N + M + 2, s = N + M, t = N + M + 1; atcoder::mf_graph<int> mf(T); for (int i = 0; i < N; i++) mf.add_edge(s, i, 1); for (int i = N; i < N + S; i++) mf.add_edge(i, t, 1); for (int i = 0; i < N; i++) mf.add_edge(i, N + get(X[i]), 1), mf.add_edge(i, N + get(Y[i]), 1); cout << mf.flow(s, t) << endl; }