結果

問題 No.2573 moving up
ユーザー 沙耶花沙耶花
提出日時 2023-12-06 02:10:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 838 ms / 2,000 ms
コード長 977 bytes
コンパイル時間 4,860 ms
コンパイル使用メモリ 278,380 KB
実行使用メモリ 39,732 KB
最終ジャッジ日時 2023-12-06 15:49:27
合計ジャッジ時間 13,553 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,676 KB
testcase_01 AC 838 ms
39,732 KB
testcase_02 AC 669 ms
39,732 KB
testcase_03 AC 641 ms
39,732 KB
testcase_04 AC 676 ms
39,732 KB
testcase_05 AC 652 ms
39,732 KB
testcase_06 AC 638 ms
39,732 KB
testcase_07 AC 631 ms
38,988 KB
testcase_08 AC 117 ms
18,396 KB
testcase_09 AC 9 ms
6,676 KB
testcase_10 AC 443 ms
34,356 KB
testcase_11 AC 128 ms
17,496 KB
testcase_12 AC 266 ms
24,480 KB
testcase_13 AC 492 ms
34,064 KB
testcase_14 AC 31 ms
8,720 KB
testcase_15 AC 51 ms
16,184 KB
testcase_16 AC 4 ms
6,676 KB
testcase_17 AC 21 ms
6,676 KB
testcase_18 AC 332 ms
29,884 KB
testcase_19 AC 434 ms
32,388 KB
testcase_20 AC 41 ms
8,980 KB
testcase_21 AC 59 ms
11,280 KB
testcase_22 AC 30 ms
6,836 KB
testcase_23 AC 94 ms
15,324 KB
testcase_24 AC 209 ms
23,860 KB
testcase_25 AC 298 ms
26,224 KB
testcase_26 AC 57 ms
10,788 KB
testcase_27 AC 40 ms
16,580 KB
testcase_28 AC 36 ms
16,580 KB
testcase_29 AC 40 ms
16,580 KB
testcase_30 AC 39 ms
16,580 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0