Download uva_cpp_clean/10074/10074-14.cpp from slayone/uva_spoj_raw: direct link, hf CLI and curl.
- Browser
- Download file 4.34 kB
-
https://huggingface.co/datasets/slayone/uva_spoj_raw/resolve/main/uva_cpp_clean/10074/10074-14.cpp
- Command line
-
hf download hf://datasets/slayone/uva_spoj_raw/uva_cpp_clean/10074/10074-14.cpp
-
curl -L -o 10074-14.cpp https://huggingface.co/datasets/slayone/uva_spoj_raw/resolve/main/uva_cpp_clean/10074/10074-14.cpp
4.34 kB
| /*************************************************** | |
| * Problem Name : 10074 - Take the Land.cpp | |
| * Problem Link : https://uva.onlinejudge.org/external/100/10074.pdf | |
| * OJ : Uva | |
| * Verdict : AC | |
| * Date : 2019-07-09 | |
| * Problem Type : DP | |
| * Author Name : Saikat Sharma | |
| * University : CSE, MBSTU | |
| ***************************************************/ | |
| using namespace std; | |
| typedef long long ll; | |
| typedef unsigned long long ull; | |
| template <typename T> | |
| std::string NumberToString ( T Number ) { | |
| std::ostringstream ss; | |
| ss << Number; | |
| return ss.str(); | |
| } | |
| ll lcm (ll a, ll b) { | |
| return a * b / __gcd (a, b); | |
| } | |
| /************************************ Code Start Here ******************************************************/ | |
| int tree[MAX * 4][MAX * 4]; | |
| int vec[MAX][MAX]; | |
| int n, m, mx; | |
| void build (int indx, int nod, int low, int high) { | |
| if (low == high) { | |
| tree[indx][nod] = low; | |
| return ; | |
| } | |
| int mid = (high + low) / 2; | |
| int left = nod * 2; | |
| int right = nod * 2 + 1; | |
| build (indx, left, low, mid); | |
| build (indx, right, mid + 1, high); | |
| if (vec[indx][tree[indx][left]] <= vec[indx][tree[indx][right]]) { | |
| tree[indx][nod] = tree[indx][left]; | |
| } else { | |
| tree[indx][nod] = tree[indx][right]; | |
| } | |
| } | |
| int query (int indx, int nod, int low, int high, int qlow, int qhigh) { | |
| if (qlow > high || qhigh < low) { | |
| return 0; | |
| } | |
| if (qlow <= low && qhigh >= high) { | |
| return tree[indx][nod]; | |
| } | |
| int mid = (high + low) / 2; | |
| int left = nod * 2; | |
| int right = nod * 2 + 1; | |
| int a = query (indx, left, low, mid, qlow, qhigh); | |
| int b = query (indx, right, mid + 1, high, qlow, qhigh); | |
| if (vec[indx][a] <= vec[indx][b]) { | |
| return a; | |
| } else { | |
| return b; | |
| } | |
| } | |
| void solve (int indx, int l, int r) { | |
| if (l > r) return ; | |
| int idx = query (indx, 1, 1, m, l, r); | |
| int xx = vec[indx][idx] * (r - l + 1); | |
| mx = max (mx, xx); | |
| solve (indx, l, idx - 1); | |
| solve (indx, idx + 1, r); | |
| } | |
| int main () { | |
| __FastIO; | |
| while (cin >> n >> m) { | |
| if (n == 0 && m == 0) break; | |
| SET (tree, 0); | |
| SET (vec, 0); | |
| int ar[MAX][MAX]; | |
| for (int i = 1; i <= n; i++) { | |
| for (int j = 1; j <= m; j++) { | |
| cin >> ar[i][j]; | |
| } | |
| } | |
| for (int i = 1; i <= n; i++) { | |
| for (int j = 1; j <= m; j++) { | |
| if (i == 1) { | |
| if (ar[i][j] == 0) { | |
| vec[i][j] = 1; | |
| } else { | |
| vec[i][j] = 0; | |
| } | |
| } else { | |
| if (ar[i][j] == 0) { | |
| vec[i][j] = vec[i - 1][j] + 1; | |
| } else { | |
| vec[i][j] = 0; | |
| } | |
| } | |
| } | |
| } | |
| for (int i = 0; i < MAX; i++) { | |
| vec[i][0] = 1000000; | |
| } | |
| int ans = 0; | |
| for (int i = 1; i <= n; i++) { | |
| build (i, 1, 1, m); | |
| } | |
| for (int i = 1; i <= n; i++) { | |
| mx = 0; | |
| solve (i, 1, m); | |
| ans = max (ans, mx); | |
| } | |
| cout << ans << "\n"; | |
| } | |
| return 0; | |
| } | |