Submission #8900666
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
int n = 0, m = 0;
char mathx[3050][3050];
bool same[3050][3050];
int up[3050][3050];
int sta[3050][2], top = 0;
signed main()
{
scanf("%d%d", &n, &m);
for(int i = 1; i <= n; i++) scanf("%s", mathx[i] + 1);
for(int i = n; i >= 1; i--)
for(int j = 1; j <= m; j++)
{
same[i][j] = (mathx[i][j] == mathx[i][j + 1]);
up[i][j] = (same[i][j] != same[i + 1][j]? 1: up[i + 1][j] + 1);
}
int ans = max(n, m);
for(int i = 1; i <= n; i++)
{
top = 0;
for(int j = 1; j <= m; j++)
{
if(top > 0)
{
#define aol(x, a, h) (h * (x - a + 1))
int x = 1, y = top, z = 0;
while(x < y)
{
z = x + ((y - x + 1) >> 1);
if(z == 1 || aol(j, sta[z - 1][1], sta[z - 1][0]) < aol(j, sta[z][1], sta[z][0])) x = z;
else if(aol(j, sta[z - 1][1], sta[z - 1][0]) > aol(j, sta[z][1], sta[z][0])) y = z - 1;
else { x = y = z; break; }
}
ans = max(ans, aol(j, sta[x][1], sta[x][0]));
}
int u = j;
while(top > 0 && sta[top][0] > up[i][j]) u = sta[top][1], top--;
if(!top || sta[top][0] < up[i][j])
top++, sta[top][0] = up[i][j], sta[top][1] = u;
}
}
cout << ans << endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
F - Flip and Rectangles |
User |
Mr_Food |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
1224 Byte |
Status |
WA |
Exec Time |
107 ms |
Memory |
41216 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:10:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &n, &m);
^
./Main.cpp:11:55: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
for(int i = 1; i <= n; i++) scanf("%s", mathx[i] + 1);
^
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 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 |
9 ms |
39808 KB |
10.txt |
AC |
105 ms |
41088 KB |
11.txt |
AC |
26 ms |
40576 KB |
12.txt |
AC |
36 ms |
41088 KB |
13.txt |
AC |
47 ms |
41216 KB |
14.txt |
AC |
48 ms |
41088 KB |
15.txt |
AC |
49 ms |
41088 KB |
16.txt |
AC |
51 ms |
41216 KB |
17.txt |
AC |
52 ms |
41216 KB |
18.txt |
AC |
107 ms |
41088 KB |
19.txt |
AC |
84 ms |
41088 KB |
2.txt |
AC |
2 ms |
4352 KB |
20.txt |
AC |
93 ms |
41088 KB |
21.txt |
AC |
95 ms |
41088 KB |
22.txt |
AC |
92 ms |
41216 KB |
23.txt |
AC |
88 ms |
41088 KB |
24.txt |
AC |
36 ms |
41216 KB |
25.txt |
AC |
36 ms |
41216 KB |
26.txt |
AC |
87 ms |
41216 KB |
27.txt |
AC |
75 ms |
41088 KB |
28.txt |
AC |
66 ms |
41088 KB |
29.txt |
AC |
38 ms |
41216 KB |
3.txt |
AC |
79 ms |
41216 KB |
30.txt |
AC |
49 ms |
41088 KB |
31.txt |
AC |
48 ms |
41088 KB |
32.txt |
AC |
51 ms |
41216 KB |
33.txt |
AC |
67 ms |
41088 KB |
34.txt |
AC |
55 ms |
41216 KB |
4.txt |
AC |
80 ms |
41216 KB |
5.txt |
AC |
9 ms |
39808 KB |
6.txt |
AC |
2 ms |
4352 KB |
7.txt |
WA |
104 ms |
41216 KB |
8.txt |
AC |
104 ms |
41216 KB |
9.txt |
AC |
106 ms |
41216 KB |
sample1.txt |
AC |
2 ms |
4352 KB |
sample2.txt |
AC |
2 ms |
4352 KB |
sample3.txt |
AC |
2 ms |
4352 KB |