結果
問題 | No.2573 moving up |
ユーザー | binap |
提出日時 | 2024-01-19 21:03:53 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,951 bytes |
コンパイル時間 | 4,382 ms |
コンパイル使用メモリ | 278,948 KB |
実行使用メモリ | 51,096 KB |
最終ジャッジ日時 | 2024-01-19 21:04:16 |
合計ジャッジ時間 | 15,448 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
6,676 KB |
testcase_01 | AC | 720 ms
51,096 KB |
testcase_02 | AC | 1,095 ms
51,096 KB |
testcase_03 | AC | 778 ms
51,096 KB |
testcase_04 | AC | 834 ms
51,096 KB |
testcase_05 | AC | 800 ms
51,096 KB |
testcase_06 | AC | 731 ms
51,096 KB |
testcase_07 | AC | 770 ms
50,164 KB |
testcase_08 | AC | 148 ms
26,800 KB |
testcase_09 | WA | - |
testcase_10 | AC | 576 ms
43,412 KB |
testcase_11 | AC | 157 ms
23,760 KB |
testcase_12 | AC | 316 ms
31,260 KB |
testcase_13 | AC | 581 ms
42,492 KB |
testcase_14 | AC | 40 ms
11,416 KB |
testcase_15 | AC | 67 ms
26,536 KB |
testcase_16 | AC | 3 ms
6,676 KB |
testcase_17 | AC | 21 ms
6,676 KB |
testcase_18 | AC | 413 ms
42,616 KB |
testcase_19 | AC | 540 ms
40,808 KB |
testcase_20 | AC | 48 ms
11,136 KB |
testcase_21 | AC | 73 ms
14,976 KB |
testcase_22 | AC | 31 ms
7,372 KB |
testcase_23 | AC | 116 ms
22,484 KB |
testcase_24 | AC | 260 ms
31,992 KB |
testcase_25 | AC | 360 ms
33,504 KB |
testcase_26 | AC | 67 ms
13,820 KB |
testcase_27 | AC | 48 ms
28,388 KB |
testcase_28 | AC | 45 ms
28,388 KB |
testcase_29 | AC | 53 ms
28,388 KB |
testcase_30 | AC | 46 ms
28,388 KB |
ソースコード
#include<bits/stdc++.h> #include<atcoder/all> #define rep(i,n) for(int i=0;i<n;i++) using namespace std; using namespace atcoder; typedef long long ll; typedef vector<int> vi; typedef vector<long long> vl; typedef vector<vector<int>> vvi; typedef vector<vector<long long>> vvl; typedef long double ld; typedef pair<int, int> P; ostream& operator<<(ostream& os, const modint& a) {os << a.val(); return os;} template <int m> ostream& operator<<(ostream& os, const static_modint<m>& a) {os << a.val(); return os;} template<typename T> istream& operator>>(istream& is, vector<T>& v){int n = v.size(); assert(n > 0); rep(i, n) is >> v[i]; return is;} template<typename U, typename T> ostream& operator<<(ostream& os, const pair<U, T>& p){os << p.first << ' ' << p.second; return os;} template<typename T> ostream& operator<<(ostream& os, const vector<T>& v){int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "\n" : " "); return os;} template <typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v){int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "\n" : ""); return os;} int main(){ int h, w; cin >> h >> w; int n = h * (h + w); mcf_graph<int, int> graph(n + 2); int sv = n; int tv = n + 1; rep(y, h) rep(x, h + w){ int from = y * (h + w) + x; if(y < h - 1){ int to = (y + 1) * (h + w) + x; graph.add_edge(from, to, 1, 1); graph.add_edge(to, from, 1, 1); } if(x < h + w - 1){ int to = y * (h + w) + (x + 1); graph.add_edge(from, to, 1, 1); graph.add_edge(to, from, 1, 1); } if(y < h - 1 and x < h + w - 1){ int to = (y + 1) * (h + w) + (x + 1); graph.add_edge(from, to, 1, 1); graph.add_edge(to, from, 1, 1); } } rep(i, w){ int y, x; cin >> y >> x; x--; y--; graph.add_edge(sv, y * (h + w) + x, 1, 0); } rep(x, w){ graph.add_edge(x, tv, 1, 0); } auto [cap, cost] = graph.flow(sv, tv); // cout << cap << ' ' << cost << "\n"; cout << cost << "\n"; return 0; }