Submission #1606089
Source Code Expand
#include <vector> #include <algorithm> #include <iostream> #include <cassert> #include <cstdlib> #include <cmath> #include <cstdio> #include <ctime> #include <queue> #include <stack> #include <map> #include <set> #include <string> #define INFLL 2000000000000000000 #define INF 2000000000 #define MOD 1000000007 #define PI acos(-1.0) using namespace std; typedef pair <int, int> pii; bool isGood[2000][2000]; bool board[2000][2000]; int up[2000][2000]; int n, m; int ll[2000], rr[2000]; int curRow; int main() { cin >> n >> m; for (int i = 0; i < n; i++) { string str; cin >> str; for (int j = 0; j < str.length(); j++) { board[i][j] = (str[j] == '#'); } } for (int i = 0; i < n - 1; i++) { for (int j = 0; j < m - 1; j++) { int cnt = 0; for (int x = 0; x < 2; x++) for (int y = 0; y < 2; y++) if (board[i + x][j + y]) cnt++; if (cnt % 2 == 0) isGood[i][j] = true; else isGood[i][j] = false; } } m--; n--; for (int i = 0; i < m; i++) if (isGood[0][i]) up[0][i] = 1; else up[0][i] = 0; for (int i = 1; i < n; i++) { for (int j = 0; j < m; j++) { if (isGood[i][j]) up[i][j] = up[i - 1][j] + 1; else up[i][j] = 0; } } int ans = max(n + 1, m + 1); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) ll[j] = rr[j] = j; stack <int> st; st.push(-1); for (int j = 0; j < m; j++) { while (st.top() != -1 && up[i][st.top()] >= up[i][j]) st.pop(); ll[j] = st.top(); st.push(j); } st = stack <int>(); st.push(m); for (int j = m - 1; j >= 0; j--) { while (st.top() != m && up[i][st.top()] >= up[i][j]) st.pop(); rr[j] = st.top(); st.push(j); } for (int j = 0; j < m; j++) { if (up[i][j] == 0) continue; ans = max(ans, (rr[j] - ll[j]) * (up[i][j] + 1)); //cout << i << " " << j << " " << ll[j] << " " << rr[j] << endl; } } cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Flip and Rectangles |
User | spiderbatman |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 1991 Byte |
Status | AC |
Exec Time | 258 ms |
Memory | 23680 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 700 / 700 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample1.txt, sample2.txt, sample3.txt |
All | sample1.txt, sample2.txt, sample3.txt, 1.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 2.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 3.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 4.txt, 5.txt, 6.txt, 7.txt, 8.txt, 9.txt, sample1.txt, sample2.txt, sample3.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
1.txt | AC | 7 ms | 22656 KB |
10.txt | AC | 223 ms | 23680 KB |
11.txt | AC | 99 ms | 23680 KB |
12.txt | AC | 180 ms | 23680 KB |
13.txt | AC | 182 ms | 23680 KB |
14.txt | AC | 182 ms | 23680 KB |
15.txt | AC | 184 ms | 23680 KB |
16.txt | AC | 184 ms | 23680 KB |
17.txt | AC | 183 ms | 23680 KB |
18.txt | AC | 235 ms | 23680 KB |
19.txt | AC | 193 ms | 23680 KB |
2.txt | AC | 2 ms | 4352 KB |
20.txt | AC | 200 ms | 23680 KB |
21.txt | AC | 197 ms | 23680 KB |
22.txt | AC | 197 ms | 23680 KB |
23.txt | AC | 201 ms | 23680 KB |
24.txt | AC | 179 ms | 23680 KB |
25.txt | AC | 179 ms | 23680 KB |
26.txt | AC | 240 ms | 23680 KB |
27.txt | AC | 226 ms | 23680 KB |
28.txt | AC | 224 ms | 23680 KB |
29.txt | AC | 178 ms | 23680 KB |
3.txt | AC | 255 ms | 23680 KB |
30.txt | AC | 185 ms | 23680 KB |
31.txt | AC | 184 ms | 23680 KB |
32.txt | AC | 184 ms | 23680 KB |
33.txt | AC | 185 ms | 23680 KB |
34.txt | AC | 187 ms | 23680 KB |
4.txt | AC | 258 ms | 23680 KB |
5.txt | AC | 8 ms | 22656 KB |
6.txt | AC | 2 ms | 4352 KB |
7.txt | AC | 248 ms | 23680 KB |
8.txt | AC | 243 ms | 23680 KB |
9.txt | AC | 225 ms | 23680 KB |
sample1.txt | AC | 2 ms | 4352 KB |
sample2.txt | AC | 2 ms | 4352 KB |
sample3.txt | AC | 2 ms | 4352 KB |