답안 #1067946

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1067946 2024-08-21T05:54:35 Z Gromp15 Rectangles (IOI19_rect) C++17
37 / 100
429 ms 1048576 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#include "rect.h"
#define ll long long
#define ar array
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using namespace std;
template<typename T> bool ckmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rint(l, r) uniform_int_distribution<int>(l, r)(rng)

long long count_rectangles(std::vector<std::vector<int>> a) {
	int n = sz(a), m = sz(a[0]);
	vector ok(n, vector(n, vector<int>(m)));
	for (int i = 0; i < m; i++) {
		for (int j = 1; j < n-1; j++) {
			int mx = 0;
			for (int k = j; k < n-1; k++) {
				ckmax(mx, a[k][i]);
				ok[j][k][i] = (mx >= min(a[j-1][i], a[k+1][i])) + (i ? ok[j][k][i-1] : 0);
			}
		}
	}
	vector ok2(m, vector(m, vector<int>(n)));
	for (int i = 0; i < n; i++) {
		for (int j = 1; j < m-1; j++) {
			int mx = 0;
			for (int k = j; k < m-1; k++) {
				ckmax(mx, a[i][k]);
				ok2[j][k][i] = (mx >= min(a[i][j-1], a[i][k+1])) + (i ? ok2[j][k][i-1] : 0);
			}
		}
	}
	long long ans = 0;
	for (int i = 1; i < n-1; i++) for (int j = i; j < n-1; j++) {
		for (int k = 1; k < m-1; k++) for (int l = k; l < m-1; l++) {
			ans += !(ok[i][j][l] - ok[i][j][k-1]) && !(ok2[k][l][j] - ok2[k][l][i-1]);
		}
	}
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 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 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 348 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 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 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 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 348 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 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 13 ms 4956 KB Output is correct
23 Correct 13 ms 4952 KB Output is correct
24 Correct 13 ms 5032 KB Output is correct
25 Correct 12 ms 4952 KB Output is correct
26 Correct 11 ms 4976 KB Output is correct
27 Correct 11 ms 4956 KB Output is correct
28 Correct 21 ms 4952 KB Output is correct
29 Correct 4 ms 2388 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 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 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 348 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 13 ms 4956 KB Output is correct
18 Correct 13 ms 4952 KB Output is correct
19 Correct 13 ms 5032 KB Output is correct
20 Correct 12 ms 4952 KB Output is correct
21 Correct 11 ms 4976 KB Output is correct
22 Correct 11 ms 4956 KB Output is correct
23 Correct 21 ms 4952 KB Output is correct
24 Correct 4 ms 2388 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 604 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 392 ms 66672 KB Output is correct
31 Correct 408 ms 66572 KB Output is correct
32 Correct 410 ms 66644 KB Output is correct
33 Correct 387 ms 66572 KB Output is correct
34 Correct 359 ms 66488 KB Output is correct
35 Correct 376 ms 66644 KB Output is correct
36 Correct 389 ms 66640 KB Output is correct
37 Correct 404 ms 64848 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 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 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 348 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 13 ms 4956 KB Output is correct
18 Correct 13 ms 4952 KB Output is correct
19 Correct 13 ms 5032 KB Output is correct
20 Correct 12 ms 4952 KB Output is correct
21 Correct 11 ms 4976 KB Output is correct
22 Correct 11 ms 4956 KB Output is correct
23 Correct 21 ms 4952 KB Output is correct
24 Correct 4 ms 2388 KB Output is correct
25 Correct 392 ms 66672 KB Output is correct
26 Correct 408 ms 66572 KB Output is correct
27 Correct 410 ms 66644 KB Output is correct
28 Correct 387 ms 66572 KB Output is correct
29 Correct 359 ms 66488 KB Output is correct
30 Correct 376 ms 66644 KB Output is correct
31 Correct 389 ms 66640 KB Output is correct
32 Correct 404 ms 64848 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 1 ms 604 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Runtime error 400 ms 1048576 KB Execution killed with signal 9
39 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 360 ms 343072 KB Output is correct
2 Correct 254 ms 247588 KB Output is correct
3 Correct 378 ms 343252 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 373 ms 343112 KB Output is correct
6 Correct 372 ms 343260 KB Output is correct
7 Correct 393 ms 343116 KB Output is correct
8 Correct 338 ms 343136 KB Output is correct
9 Correct 318 ms 343124 KB Output is correct
10 Correct 300 ms 343120 KB Output is correct
11 Correct 333 ms 343044 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Runtime error 429 ms 1048576 KB Execution killed with signal 9
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 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 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 348 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 13 ms 4956 KB Output is correct
18 Correct 13 ms 4952 KB Output is correct
19 Correct 13 ms 5032 KB Output is correct
20 Correct 12 ms 4952 KB Output is correct
21 Correct 11 ms 4976 KB Output is correct
22 Correct 11 ms 4956 KB Output is correct
23 Correct 21 ms 4952 KB Output is correct
24 Correct 4 ms 2388 KB Output is correct
25 Correct 392 ms 66672 KB Output is correct
26 Correct 408 ms 66572 KB Output is correct
27 Correct 410 ms 66644 KB Output is correct
28 Correct 387 ms 66572 KB Output is correct
29 Correct 359 ms 66488 KB Output is correct
30 Correct 376 ms 66644 KB Output is correct
31 Correct 389 ms 66640 KB Output is correct
32 Correct 404 ms 64848 KB Output is correct
33 Runtime error 400 ms 1048576 KB Execution killed with signal 9
34 Halted 0 ms 0 KB -