# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1017980 |
2024-07-09T12:14:58 Z |
c2zi6 |
Rectangles (IOI19_rect) |
C++14 |
|
5000 ms |
521920 KB |
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define replr(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define reprl(i, a, b) for (int i = int(a); i >= int(b); --i)
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define mkp(a, b) make_pair(a, b)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<VPI> VVPI;
typedef pair<ll, ll> PLL;
typedef vector<ll> VL;
typedef vector<PLL> VPL;
typedef vector<VL> VVL;
typedef vector<VVL> VVVL;
typedef vector<VPL> VVPL;
template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;}
template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;}
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T>
using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#include "rect.h"
int lg[3001];
struct SPARSETABLE {
VVI table;
SPARSETABLE(){};
SPARSETABLE(VI a) {
int n = a.size();
table = VVI(n, VI(14));
reprl(i, n-1, 0) {
table[i][0] = a[i];
for (int j = 1; i+(1<<(j-1)) < n; j++) {
table[i][j] = max(table[i][j-1], table[i + (1<<(j-1))][j-1]);
}
}
}
int get(int l, int r) {
int s = lg[r - l + 1];
return max(table[l][s], table[r-(1<<s)+1][s]);
}
};
ll count_rectangles(VVI a) {
lg[1] = 0; replr(i, 2, 3000) lg[i] = lg[i/2]+1;
int n = a.size();
int m = a[0].size();
vector<SPARSETABLE> rows(n);
vector<SPARSETABLE> cols(m);
rep(i, n) {
rows[i] = SPARSETABLE(a[i]);
}
rep(j, m) {
VI b;
rep(i, n) b.pb(a[i][j]);
cols[j] = SPARSETABLE(b);
}
ll ans = 0;
replr(r1, 1, n-2) replr(r2, r1, n-2) {
replr(c1, 1, m-2) replr(c2, c1, m-2) {
bool good = true;
replr(i, r1, r2) {
if (rows[i].get(c1, c2) >= min(a[i][c1-1], a[i][c2+1])) {
good = false;
break;
}
}
if (!good) continue;
replr(j, c1, c2) {
if (cols[j].get(r1, r2) >= min(a[r1-1][j], a[r2+1][j])) {
good = false;
break;
}
}
if (!good) continue;
/*cout << r1 << " " << r2 << " " << c1 << " " << c2 << endl;*/
ans++;
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
604 KB |
Output is correct |
3 |
Correct |
2 ms |
600 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
436 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
396 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
600 KB |
Output is correct |
12 |
Correct |
1 ms |
624 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
600 KB |
Output is correct |
15 |
Correct |
0 ms |
600 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 |
432 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
604 KB |
Output is correct |
3 |
Correct |
2 ms |
600 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
436 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
396 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
600 KB |
Output is correct |
12 |
Correct |
1 ms |
624 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
600 KB |
Output is correct |
15 |
Correct |
0 ms |
600 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 |
432 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
58 ms |
1628 KB |
Output is correct |
23 |
Correct |
52 ms |
1628 KB |
Output is correct |
24 |
Correct |
53 ms |
1628 KB |
Output is correct |
25 |
Correct |
33 ms |
1372 KB |
Output is correct |
26 |
Correct |
39 ms |
1372 KB |
Output is correct |
27 |
Correct |
33 ms |
1628 KB |
Output is correct |
28 |
Correct |
34 ms |
1628 KB |
Output is correct |
29 |
Correct |
9 ms |
860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
604 KB |
Output is correct |
3 |
Correct |
2 ms |
600 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
436 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
396 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
600 KB |
Output is correct |
12 |
Correct |
1 ms |
624 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
600 KB |
Output is correct |
15 |
Correct |
0 ms |
600 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
58 ms |
1628 KB |
Output is correct |
18 |
Correct |
52 ms |
1628 KB |
Output is correct |
19 |
Correct |
53 ms |
1628 KB |
Output is correct |
20 |
Correct |
33 ms |
1372 KB |
Output is correct |
21 |
Correct |
39 ms |
1372 KB |
Output is correct |
22 |
Correct |
33 ms |
1628 KB |
Output is correct |
23 |
Correct |
34 ms |
1628 KB |
Output is correct |
24 |
Correct |
9 ms |
860 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 |
432 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
2575 ms |
7876 KB |
Output is correct |
31 |
Correct |
2610 ms |
7876 KB |
Output is correct |
32 |
Correct |
2581 ms |
7768 KB |
Output is correct |
33 |
Correct |
1283 ms |
7732 KB |
Output is correct |
34 |
Correct |
1306 ms |
7800 KB |
Output is correct |
35 |
Correct |
1270 ms |
7772 KB |
Output is correct |
36 |
Correct |
1276 ms |
7768 KB |
Output is correct |
37 |
Correct |
1277 ms |
7608 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
604 KB |
Output is correct |
3 |
Correct |
2 ms |
600 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
436 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
396 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
600 KB |
Output is correct |
12 |
Correct |
1 ms |
624 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
600 KB |
Output is correct |
15 |
Correct |
0 ms |
600 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
58 ms |
1628 KB |
Output is correct |
18 |
Correct |
52 ms |
1628 KB |
Output is correct |
19 |
Correct |
53 ms |
1628 KB |
Output is correct |
20 |
Correct |
33 ms |
1372 KB |
Output is correct |
21 |
Correct |
39 ms |
1372 KB |
Output is correct |
22 |
Correct |
33 ms |
1628 KB |
Output is correct |
23 |
Correct |
34 ms |
1628 KB |
Output is correct |
24 |
Correct |
9 ms |
860 KB |
Output is correct |
25 |
Correct |
2575 ms |
7876 KB |
Output is correct |
26 |
Correct |
2610 ms |
7876 KB |
Output is correct |
27 |
Correct |
2581 ms |
7768 KB |
Output is correct |
28 |
Correct |
1283 ms |
7732 KB |
Output is correct |
29 |
Correct |
1306 ms |
7800 KB |
Output is correct |
30 |
Correct |
1270 ms |
7772 KB |
Output is correct |
31 |
Correct |
1276 ms |
7768 KB |
Output is correct |
32 |
Correct |
1277 ms |
7608 KB |
Output is correct |
33 |
Correct |
0 ms |
348 KB |
Output is correct |
34 |
Correct |
0 ms |
348 KB |
Output is correct |
35 |
Correct |
1 ms |
432 KB |
Output is correct |
36 |
Correct |
1 ms |
348 KB |
Output is correct |
37 |
Correct |
0 ms |
348 KB |
Output is correct |
38 |
Execution timed out |
5034 ms |
91828 KB |
Time limit exceeded |
39 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
1808 KB |
Output is correct |
2 |
Correct |
14 ms |
1628 KB |
Output is correct |
3 |
Correct |
11 ms |
1884 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
16 ms |
1928 KB |
Output is correct |
6 |
Correct |
14 ms |
1884 KB |
Output is correct |
7 |
Correct |
12 ms |
1884 KB |
Output is correct |
8 |
Correct |
12 ms |
1904 KB |
Output is correct |
9 |
Correct |
12 ms |
1884 KB |
Output is correct |
10 |
Correct |
1 ms |
860 KB |
Output is correct |
11 |
Correct |
1 ms |
1372 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 |
432 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Execution timed out |
5087 ms |
521920 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
604 KB |
Output is correct |
3 |
Correct |
2 ms |
600 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
436 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
396 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
600 KB |
Output is correct |
12 |
Correct |
1 ms |
624 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
600 KB |
Output is correct |
15 |
Correct |
0 ms |
600 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
58 ms |
1628 KB |
Output is correct |
18 |
Correct |
52 ms |
1628 KB |
Output is correct |
19 |
Correct |
53 ms |
1628 KB |
Output is correct |
20 |
Correct |
33 ms |
1372 KB |
Output is correct |
21 |
Correct |
39 ms |
1372 KB |
Output is correct |
22 |
Correct |
33 ms |
1628 KB |
Output is correct |
23 |
Correct |
34 ms |
1628 KB |
Output is correct |
24 |
Correct |
9 ms |
860 KB |
Output is correct |
25 |
Correct |
2575 ms |
7876 KB |
Output is correct |
26 |
Correct |
2610 ms |
7876 KB |
Output is correct |
27 |
Correct |
2581 ms |
7768 KB |
Output is correct |
28 |
Correct |
1283 ms |
7732 KB |
Output is correct |
29 |
Correct |
1306 ms |
7800 KB |
Output is correct |
30 |
Correct |
1270 ms |
7772 KB |
Output is correct |
31 |
Correct |
1276 ms |
7768 KB |
Output is correct |
32 |
Correct |
1277 ms |
7608 KB |
Output is correct |
33 |
Execution timed out |
5034 ms |
91828 KB |
Time limit exceeded |
34 |
Halted |
0 ms |
0 KB |
- |