結果
問題 | No.2238 Rock and Hole |
ユーザー | 沙耶花 |
提出日時 | 2023-03-03 22:01:28 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 58 ms / 3,000 ms |
コード長 | 1,096 bytes |
コンパイル時間 | 4,889 ms |
コンパイル使用メモリ | 271,024 KB |
実行使用メモリ | 17,448 KB |
最終ジャッジ日時 | 2023-10-18 02:03:12 |
合計ジャッジ時間 | 6,474 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,348 KB |
testcase_01 | AC | 2 ms
4,348 KB |
testcase_02 | AC | 2 ms
4,348 KB |
testcase_03 | AC | 2 ms
4,348 KB |
testcase_04 | AC | 2 ms
4,348 KB |
testcase_05 | AC | 2 ms
4,348 KB |
testcase_06 | AC | 2 ms
4,348 KB |
testcase_07 | AC | 2 ms
4,348 KB |
testcase_08 | AC | 2 ms
4,348 KB |
testcase_09 | AC | 2 ms
4,348 KB |
testcase_10 | AC | 4 ms
4,348 KB |
testcase_11 | AC | 13 ms
9,064 KB |
testcase_12 | AC | 14 ms
9,480 KB |
testcase_13 | AC | 13 ms
8,760 KB |
testcase_14 | AC | 7 ms
6,228 KB |
testcase_15 | AC | 5 ms
4,764 KB |
testcase_16 | AC | 58 ms
17,448 KB |
testcase_17 | AC | 39 ms
16,972 KB |
testcase_18 | AC | 19 ms
11,716 KB |
testcase_19 | AC | 43 ms
9,016 KB |
testcase_20 | AC | 26 ms
9,804 KB |
testcase_21 | AC | 28 ms
9,232 KB |
testcase_22 | AC | 17 ms
8,140 KB |
testcase_23 | AC | 2 ms
4,348 KB |
ソースコード
#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<string> s(h); rep(i,h)cin>>s[i]; vector<pair<int,int>> rs,hs; rep(i,h){ rep(j,w){ if(s[i][j]=='h')hs.emplace_back(i,j); if(s[i][j]=='r')rs.emplace_back(i,j); } } int x = rs.size(); int y = hs.size(); mf_graph<int> G(x + y + 2); vector<int> dx = {1,-1,0,0},dy = {0,0,1,-1}; int S = x + y; int T = S + 1; rep(i,x){ G.add_edge(S,i,1); rep(j,4){ int xx = rs[i].first,yy = rs[i].second; while(true){ xx += dx[j]; yy += dy[j]; if(xx<0||xx>=h||yy<0||yy>=w)break; if(s[xx][yy]=='h'){ int ii = distance(hs.begin(),lower_bound(hs.begin(),hs.end(),make_pair(xx,yy))); G.add_edge(i,x + ii,1); break; } } } } rep(i,y){ G.add_edge(x + i,T,1); } if(G.flow(S,T)==x)cout<<"Yes"<<endl; else cout<<"No"<<endl; return 0; }