Submission #3426662
Source Code Expand
#include<iostream> #include<string> #include<cstdio> #include<vector> #include<cmath> #include<algorithm> #include<functional> #include<iomanip> #include<queue> #include<ciso646> #include<random> #include<map> #include<set> #include<complex> #include<bitset> #include<stack> #include<unordered_map> using namespace std; typedef long long ll; typedef unsigned int ui; const ll mod = (ll)(1e+9) + 7; const ll INF = (ll)1000000007 * 1000000007; typedef pair<int, int> P; #define stop char nyaa;cin>>nyaa; #define rep(i,n) for(int i=0;i<n;i++) #define per(i,n) for(int i=n-1;i>=0;i--) #define Rep(i,sta,n) for(int i=sta;i<n;i++) #define rep1(i,n) for(int i=1;i<=n;i++) #define per1(i,n) for(int i=n;i>=1;i--) #define Rep1(i,sta,n) for(int i=sta;i<=n;i++) typedef long double ld; typedef complex<ld> Point; const ld eps = 1e-12; const ld pi = acos(-1.0); typedef pair<ll, ll> LP; typedef pair<ld, ld> LDP; #include<cstring> struct edge { int to, cap, rev; }; vector<edge> G[100000]; bool used[100000]; void add_edge(int from, int to, int cap) { G[from].push_back(edge{ to, cap, (int)G[to].size() }); G[to].push_back(edge{ from, 0, (int)G[from].size() - 1 }); } int dfs(int v, int t, int f) { if (v == t)return f; used[v] = true; for (int i = 0; i < (int)G[v].size(); i++) { edge &e = G[v][i]; if (!used[e.to] && e.cap > 0) { int d = dfs(e.to, t, min(f, e.cap)); if (d > 0) { e.cap -= d; G[e.to][e.rev].cap += d; return d; } } } return 0; } int max_flow(int s, int t) { int flow = 0; for (;;) { memset(used, 0, sizeof(used)); int f = dfs(s, t, mod); if (f == 0)return flow; flow += f; } } char lake[100][100]; int main() { int h, w; cin >> h >> w; int sta, goal; rep(i, h) { rep(j, w) { cin >> lake[i][j]; if (lake[i][j] == 'S') { sta = i * w + j; } else if (lake[i][j] == 'T') { goal = i * w + j; } } } rep(i, h) { rep(j, w) { if (lake[i][j] == '.')continue; rep(k, w) { if (lake[i][k] == '.')continue; add_edge(i*w + j, i*w + k, 1); } rep(k, h) { if (lake[k][j] == '.')continue; add_edge(i*w + j, k*w + j, 1); } } } cout << max_flow(sta, goal) << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Lotus Leaves |
User | heno239 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 2276 Byte |
Status | WA |
Exec Time | 1367 ms |
Memory | 65152 KB |
Judge Result
Set Name | Sample | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 800 | ||||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt, 1_26.txt, 1_27.txt, 1_28.txt, 1_29.txt, 1_30.txt, 1_31.txt, 1_32.txt, 1_33.txt, 1_34.txt, 1_35.txt, 1_36.txt, 1_37.txt, 1_38.txt, 1_39.txt, 1_40.txt, 1_41.txt, 1_42.txt, 1_43.txt, 1_44.txt, 1_45.txt, 1_46.txt, 1_47.txt, 1_48.txt, 1_49.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 2 ms | 2688 KB |
0_01.txt | AC | 2 ms | 2688 KB |
0_02.txt | WA | 2 ms | 2688 KB |
0_03.txt | WA | 2 ms | 2688 KB |
1_00.txt | WA | 2 ms | 2688 KB |
1_01.txt | WA | 2 ms | 2688 KB |
1_02.txt | AC | 2 ms | 2688 KB |
1_03.txt | AC | 2 ms | 2688 KB |
1_04.txt | AC | 3 ms | 2688 KB |
1_05.txt | AC | 31 ms | 18560 KB |
1_06.txt | AC | 1367 ms | 65152 KB |
1_07.txt | WA | 3 ms | 2688 KB |
1_08.txt | WA | 37 ms | 17920 KB |
1_09.txt | WA | 801 ms | 65152 KB |
1_10.txt | WA | 9 ms | 4352 KB |
1_11.txt | AC | 13 ms | 5760 KB |
1_12.txt | AC | 3 ms | 2688 KB |
1_13.txt | AC | 42 ms | 10752 KB |
1_14.txt | WA | 40 ms | 11136 KB |
1_15.txt | WA | 78 ms | 14592 KB |
1_16.txt | WA | 9 ms | 4352 KB |
1_17.txt | AC | 9 ms | 6016 KB |
1_18.txt | AC | 6 ms | 3712 KB |
1_19.txt | AC | 35 ms | 8192 KB |
1_20.txt | WA | 53 ms | 14208 KB |
1_21.txt | AC | 4 ms | 2944 KB |
1_22.txt | WA | 68 ms | 13824 KB |
1_23.txt | WA | 48 ms | 10496 KB |
1_24.txt | WA | 4 ms | 3200 KB |
1_25.txt | AC | 21 ms | 15360 KB |
1_26.txt | AC | 19 ms | 13440 KB |
1_27.txt | WA | 14 ms | 5376 KB |
1_28.txt | WA | 8 ms | 4224 KB |
1_29.txt | WA | 26 ms | 7040 KB |
1_30.txt | AC | 11 ms | 7808 KB |
1_31.txt | WA | 92 ms | 15872 KB |
1_32.txt | AC | 100 ms | 15360 KB |
1_33.txt | AC | 3 ms | 2688 KB |
1_34.txt | WA | 48 ms | 11136 KB |
1_35.txt | AC | 36 ms | 10752 KB |
1_36.txt | WA | 73 ms | 13696 KB |
1_37.txt | AC | 76 ms | 15104 KB |
1_38.txt | AC | 15 ms | 11008 KB |
1_39.txt | WA | 91 ms | 15616 KB |
1_40.txt | WA | 5 ms | 3200 KB |
1_41.txt | WA | 68 ms | 14976 KB |
1_42.txt | WA | 3 ms | 2688 KB |
1_43.txt | WA | 21 ms | 5888 KB |
1_44.txt | WA | 3 ms | 2688 KB |
1_45.txt | WA | 9 ms | 4352 KB |
1_46.txt | WA | 6 ms | 3584 KB |
1_47.txt | WA | 3 ms | 2688 KB |
1_48.txt | WA | 27 ms | 6656 KB |
1_49.txt | WA | 22 ms | 9984 KB |