Submission #1032366

# Submission time Handle Problem Language Result Execution time Memory
1032366 2024-07-23T16:16:19 Z shmax Rectangles (IOI19_rect) C++17
25 / 100
5000 ms 28544 KB
#include "rect.h"
#include <bits/stdc++.h>

#pragma GCC optimize("Ofast")
#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>;

long long count_rectangles(std::vector<std::vector<i32>> a) {
    int n = len(a);
    int m = len(a[0]);
    int ans = 0;
    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;
            vec<bool> good_layers(n, true);
            vec<int> mx(n, 0);
            for (int k = j; k < m - 1; k++) {
                int mxs = 0;
                if (a[i][k] >= a[i - 1][k]) break;
                int del = 1;
                for (int l = i; l < n - 1; l++) {
                    bool good = true;
                    {
                        int h = k;
                        mx[l] = max(mx[l], (int) a[l][h]);
                        mxs = max(mxs, (int) a[l][h]);
                        if (mxs >= min(a[i - 1][h], a[l + 1][h])) {
                            good = false;
                        }

                    }
                    good_layers[l] = good and good_layers[l];
                    if (mx[l] >= min(a[l][j - 1], a[l][k + 1])) {
                        good = false;
                        del = 0;
                        continue;
                    }
                    if (!good_layers[l]) continue;
                    if (!good) continue;
                    good_layers[l] = true;
                    ans += del;
                }
            }
        }
    }
    return ans;
}
 
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 5 ms 448 KB Output is correct
3 Correct 5 ms 348 KB Output is correct
4 Correct 5 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 428 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 5 ms 448 KB Output is correct
3 Correct 5 ms 348 KB Output is correct
4 Correct 5 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 428 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 251 ms 600 KB Output is correct
23 Correct 250 ms 344 KB Output is correct
24 Correct 249 ms 592 KB Output is correct
25 Correct 4 ms 348 KB Output is correct
26 Correct 7 ms 508 KB Output is correct
27 Correct 7 ms 344 KB Output is correct
28 Correct 12 ms 348 KB Output is correct
29 Correct 5 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 5 ms 448 KB Output is correct
3 Correct 5 ms 348 KB Output is correct
4 Correct 5 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 428 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 251 ms 600 KB Output is correct
18 Correct 250 ms 344 KB Output is correct
19 Correct 249 ms 592 KB Output is correct
20 Correct 4 ms 348 KB Output is correct
21 Correct 7 ms 508 KB Output is correct
22 Correct 7 ms 344 KB Output is correct
23 Correct 12 ms 348 KB Output is correct
24 Correct 5 ms 344 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Execution timed out 5059 ms 860 KB Time limit exceeded
31 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 5 ms 448 KB Output is correct
3 Correct 5 ms 348 KB Output is correct
4 Correct 5 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 428 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 251 ms 600 KB Output is correct
18 Correct 250 ms 344 KB Output is correct
19 Correct 249 ms 592 KB Output is correct
20 Correct 4 ms 348 KB Output is correct
21 Correct 7 ms 508 KB Output is correct
22 Correct 7 ms 344 KB Output is correct
23 Correct 12 ms 348 KB Output is correct
24 Correct 5 ms 344 KB Output is correct
25 Execution timed out 5059 ms 860 KB Time limit exceeded
26 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 95 ms 348 KB Output is correct
2 Correct 68 ms 516 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 532 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Execution timed out 5017 ms 28544 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 5 ms 448 KB Output is correct
3 Correct 5 ms 348 KB Output is correct
4 Correct 5 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 428 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 251 ms 600 KB Output is correct
18 Correct 250 ms 344 KB Output is correct
19 Correct 249 ms 592 KB Output is correct
20 Correct 4 ms 348 KB Output is correct
21 Correct 7 ms 508 KB Output is correct
22 Correct 7 ms 344 KB Output is correct
23 Correct 12 ms 348 KB Output is correct
24 Correct 5 ms 344 KB Output is correct
25 Execution timed out 5059 ms 860 KB Time limit exceeded
26 Halted 0 ms 0 KB -