結果
問題 | No.2573 moving up |
ユーザー |
![]() |
提出日時 | 2023-12-06 02:10:10 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 707 ms / 2,000 ms |
コード長 | 977 bytes |
コンパイル時間 | 4,314 ms |
コンパイル使用メモリ | 266,072 KB |
最終ジャッジ日時 | 2025-02-18 08:14:45 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 31 |
ソースコード
#include <stdio.h>#include <atcoder/all>#include <bits/stdc++.h>using namespace std;using namespace atcoder;using mint = modint998244353;#define rep(i,n) for (int i = 0; i < (n); ++i)#define Inf32 1000000001#define Inf64 4000000000000000001int main(){int H,W;cin>>H>>W;vector<pair<int,int>> p;rep(i,H){rep(j,W+i){p.emplace_back(i,j);}}mcf_graph<int,int> G(p.size()+2);int S = p.size(),T = p.size()+1;vector<int> dx = {-1,-1,0,0,1,1},dy = {-1,0,-1,1,0,1};rep(i,p.size()){rep(j,6){int ii = p[i].first + dx[j],jj = p[i].second + dy[j];int d = distance(p.begin(),lower_bound(p.begin(),p.end(),make_pair(ii,jj)));if(d==p.size() || p[d]!=make_pair(ii,jj))continue;G.add_edge(i,d,10000,1);}}rep(i,W)G.add_edge(i,T,1,0);rep(i,W){int x,y;cin>>x>>y;x--,y--;int d = distance(p.begin(),lower_bound(p.begin(),p.end(),make_pair(x,y)));G.add_edge(S,d,1,0);}cout<<G.flow(S,T).second<<endl;return 0;}