답안 #1032388

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1032388 2024-07-23T16:42:33 Z shmax Rectangles (IOI19_rect) C++17
10 / 100
3044 ms 1048576 KB
#include "rect.h"
#include <bits/stdc++.h>

//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,bmi,bmi2")

using namespace std;
using i32 = int;
//#define int long long
#define len(x) (int)(x.size())
#define inf 1000'000'000'000'000'000LL
#define all(x) x.begin(), x.end()
#define low_bit(x) (x & (-x))

template<typename T>
using vec = vector<T>;

const int maxM = 701;

long long count_rectangles(std::vector<std::vector<i32>> a) {
    int n = len(a);
    int m = len(a[0]);
    long long ans = 0;
    vec<vec<bitset<maxM>>> b(n, vec<bitset<maxM>>(m));
    for (int i = 1; i < n - 1; i++) {
        for (int j = 1; j < m - 1; j++) {
            b[i][j].reset();
            int mx = a[i][j];
            for (int l = i; l < n - 1; l++) {
                mx = max(mx, a[l][j]);
                if (mx >= min(a[i - 1][j], a[l + 1][j])) continue;
                b[i][j][l] = true;
            }

        }
    }

    vec<vec<bitset<maxM>>> good(m, vec<bitset<maxM>>(m));

    vec<vec<vec<int>>> maxVal(n, vec<vec<int>>(m, vec<int>(m, 0)));
    for (int i = 1; i < n - 1; i++) {
        for (int l = 1; l < m - 1; l++) {
            for (int r = l; r < m - 1; r++) {
                maxVal[i][l][r] = max(maxVal[i][l][r - 1], a[i][r]);
            }
        }
    }
    for (int l = 1; l < m - 1; l++) {
        for (int r = l; r < m - 1; r++) {
            for (int i = 0; i < n; i++) {
                good[l][r][i] = maxVal[i][l][r] < min(a[i][l - 1], a[i][r + 1]);
            }
        }
    }
    


    for (int i = 1; i < n - 1; i++) {
        for (int j = 1; j < m - 1; j++) {
            if (a[i][j] >= a[i - 1][j]) continue;
            if (a[i][j] >= a[i][j - 1]) continue;
            bitset<maxM> cur = b[i][j];
            for (int k = j; k < m - 1; k++) {

                cur &= b[i][k];
                ans += (cur & good[j][k]).count();
            }
        }
    }

    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 411 ms 637608 KB Output is correct
2 Correct 290 ms 459924 KB Output is correct
3 Correct 268 ms 637560 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 315 ms 637620 KB Output is correct
6 Correct 308 ms 637456 KB Output is correct
7 Correct 306 ms 637524 KB Output is correct
8 Correct 299 ms 637516 KB Output is correct
9 Correct 289 ms 637560 KB Output is correct
10 Correct 226 ms 587900 KB Output is correct
11 Correct 256 ms 612728 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Runtime error 3044 ms 1048576 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -