結果
問題 | No.2573 moving up |
ユーザー |
![]() |
提出日時 | 2023-12-06 02:10:10 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 741 ms / 2,000 ms |
コード長 | 977 bytes |
コンパイル時間 | 4,088 ms |
コンパイル使用メモリ | 268,564 KB |
実行使用メモリ | 39,400 KB |
最終ジャッジ日時 | 2025-06-20 11:17:41 |
合計ジャッジ時間 | 12,656 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 32 |
ソースコード
#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 4000000000000000001 int 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; }