提出 #1532076


ソースコード 拡げる

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int maxn = 2000+10;

int mat[maxn][maxn]; 
int up[maxn], left[maxn], right[maxn];
int org[maxn][maxn];
int H, W;

////////////辅助函数////////////
inline bool check(int x, int y) {
  return (org[x-1][y-1]^org[x-1][y]^org[x][y-1]^org[x][y]);
}

////////////主要函数////////////
void init() {
  scanf("%d%d", &H, &W);
  for (int i=0; i<H; i++) 
    for (int j=0; j<W; j++) {
      int ch = getchar();
      while (ch!='#' && ch!='.') ch = getchar();
      org[i][j] = (ch == '#' ? 1 : 0);
    }
  for (int i=1; i<H; i++)
    for (int j=1; j<W; j++)
      if (check(i, j)) mat[i][j] = 1;
}

void solve() {
  int ans = 0;
  for (int j=0; j<=W; j++) up[j]=0, left[j]=0, right[j]=W;
  for (int i=1; i<=H; i++) {
    int lo = 0, ro = W;
    for (int j=0; j<=W; j++) 
      if (mat[i-1][j]) up[j]=1, left[j]=0, lo=j;
      else {
	up[j] = up[j] + 1;
	left[j] = max(left[j], lo);
      }
    for (int j=W; j>=0; j--) {
      if (mat[i-1][j]) right[j] = W, ro = j;
      else right[j] = min(right[j], ro);
      ans = max(ans, up[j] * (right[j] - left[j]));      
    }
  }
  printf("%d\n", ans);
}

int main() {
  init();
  solve();
  return 0;
}

提出情報

提出日時
問題 F - Flip and Rectangles
ユーザ RFisher
言語 C++14 (GCC 5.4.1)
得点 700
コード長 1288 Byte
結果 AC
実行時間 114 ms
メモリ 31616 KB

コンパイルエラー

./Main.cpp: In function ‘void init()’:
./Main.cpp:20:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &H, &W);
                        ^

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 700 / 700
結果
AC × 3
AC × 40
セット名 テストケース
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
ケース名 結果 実行時間 メモリ
1.txt AC 7 ms 30208 KB
10.txt AC 70 ms 31360 KB
11.txt AC 39 ms 22656 KB
12.txt AC 67 ms 18560 KB
13.txt AC 70 ms 28800 KB
14.txt AC 70 ms 30848 KB
15.txt AC 69 ms 28800 KB
16.txt AC 71 ms 30848 KB
17.txt AC 70 ms 28800 KB
18.txt AC 71 ms 31616 KB
19.txt AC 70 ms 31232 KB
2.txt AC 1 ms 2176 KB
20.txt AC 70 ms 31360 KB
21.txt AC 70 ms 31360 KB
22.txt AC 70 ms 31360 KB
23.txt AC 70 ms 31360 KB
24.txt AC 67 ms 16512 KB
25.txt AC 67 ms 16512 KB
26.txt AC 76 ms 31616 KB
27.txt AC 79 ms 31488 KB
28.txt AC 93 ms 31616 KB
29.txt AC 68 ms 31616 KB
3.txt AC 114 ms 31616 KB
30.txt AC 69 ms 31616 KB
31.txt AC 70 ms 31616 KB
32.txt AC 70 ms 31488 KB
33.txt AC 71 ms 31360 KB
34.txt AC 70 ms 31360 KB
4.txt AC 113 ms 31616 KB
5.txt AC 4 ms 17536 KB
6.txt AC 1 ms 2176 KB
7.txt AC 71 ms 31616 KB
8.txt AC 72 ms 31616 KB
9.txt AC 71 ms 31360 KB
sample1.txt AC 1 ms 2176 KB
sample2.txt AC 1 ms 2176 KB
sample3.txt AC 1 ms 2304 KB