Submission #1747968


Source Code Expand

#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iomanip>
using namespace std;

#define REP(i,n) for(long long (i)=0;(i)<(long long)(n);(i)++)
#define RREP(i,n) for(long long (i)=(long long)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

template <class T> struct FenwickTree2D {

    vector < vector < T > > node;
    FenwickTree2D (int h, int w) : node(h, vector < T > (w, 0)) {}

    void add(int x, int y, T val) {
        for (int i = x; i < node.size(); i |= i + 1) {
            for (int j = y; j < node[i].size(); j |= j + 1) {
                node[i][j] += val;
            }
        }
    }

    T sum(int x, int y) {
        T ret = 0;
        for (int i = x - 1; i >= 0; i = (i & (i + 1)) - 1) {
            for (int j = y - 1; j >= 0; j = (j & (j + 1)) - 1) {
                ret += node[i][j];
            }
        }
        return ret;
    }

    T sum(int x1, int y1, int x2, int y2) {
        return sum(x2, y2) - sum(x2, y1) - sum(x1, y2) + sum(x1, y1);
    }

};

FenwickTree2D < int > inst1(110, 110);
FenwickTree2D < int > inst2(110, 110);

int main() {

  int H,W; cin >> H >> W;
  REP(i,H) REP(j,W) {
    int t; cin >> t;
    if ((i + j) % 2 == 1) {
      inst1.add(i, j, t);
    } else {
      inst2.add(i, j, t);
    }
  }

  int ans = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      for (int k = i + 1; k <= H; k++) {
        for (int l = j + 1; l <= W; l++) {
          int a = inst1.sum(i, j, k, l);
          int b = inst2.sum(i, j, k, l);
          if (a == b) ans = max(ans, (k - i) * (l - j));
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Submission Info

Submission Time
Task B - チョコレート
User kosakkun
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2119 Byte
Status TLE
Exec Time 2103 ms
Memory 384 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 100
Status
AC × 5
AC × 17
TLE × 8
Set Name Test Cases
Sample subtask0_sample-01.txt, subtask0_sample-02.txt, subtask0_sample-03.txt, subtask0_sample-04.txt, subtask0_sample-05.txt
All subtask0_sample-01.txt, subtask0_sample-02.txt, subtask0_sample-03.txt, subtask0_sample-04.txt, subtask0_sample-05.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_20.txt
Case Name Status Exec Time Memory
subtask0_sample-01.txt AC 1 ms 384 KB
subtask0_sample-02.txt AC 1 ms 384 KB
subtask0_sample-03.txt AC 1 ms 384 KB
subtask0_sample-04.txt AC 1 ms 384 KB
subtask0_sample-05.txt AC 1 ms 384 KB
subtask1_01.txt AC 1 ms 384 KB
subtask1_02.txt AC 1 ms 384 KB
subtask1_03.txt AC 1 ms 384 KB
subtask1_04.txt AC 1 ms 384 KB
subtask1_05.txt AC 3 ms 384 KB
subtask1_06.txt AC 7 ms 384 KB
subtask1_07.txt AC 1 ms 384 KB
subtask1_08.txt AC 2 ms 384 KB
subtask1_09.txt TLE 2103 ms 384 KB
subtask1_10.txt AC 263 ms 384 KB
subtask1_11.txt TLE 2103 ms 384 KB
subtask1_12.txt TLE 2103 ms 384 KB
subtask1_13.txt TLE 2103 ms 384 KB
subtask1_14.txt TLE 2103 ms 384 KB
subtask1_15.txt TLE 2103 ms 384 KB
subtask1_16.txt TLE 2103 ms 384 KB
subtask1_17.txt AC 1834 ms 384 KB
subtask1_18.txt AC 1 ms 384 KB
subtask1_19.txt AC 2 ms 384 KB
subtask1_20.txt TLE 2103 ms 384 KB