# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
295255 | Atill83 | Rectangles (IOI19_rect) | C++14 | 989 ms | 82296 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "rect.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = (int) 205;
bool hori[MAXN][MAXN][MAXN], verti[MAXN][MAXN][MAXN];
int ph[MAXN][MAXN][MAXN], pv[MAXN][MAXN][MAXN];
long long count_rectangles(vector<vector<int>> a) {
ll ans = 0;
int n = a.size();
int m = a[0].size();
if(n <= 200 && m <= 200){
for(int i = 0; i < n; i++){
for(int j = 0; j + 1 < m; j++){
int mx = a[i][j + 1];
for(int l = j + 2; l < m; l++){
hori[i][j][l] = (min(a[i][l], a[i][j]) > mx);
mx = max(mx, a[i][l]);
if(mx > a[i][j]) break;
}
}
}
for(int j = 0; j < m; j++){
for(int i = 0; i + 1 < n; i++){
int mx = a[i + 1][j];
for(int k = i + 2; k < n; k++){
verti[i][j][k] = (min(a[k][j] , a[i][j]) > mx);
mx = max(mx, a[k][j]);
if(mx > a[i][j]) break;
}
}
}
for(int l = 3; l <= m; l++){
for(int j = 0; j <= m - l; j++){
for(int i = 0; i < n; i++){
int pre = (i == 0 ? 0 : ph[i - 1][j][l]);
ph[i][j][l] = pre + hori[i][j][j + l - 1];
}
}
}
for(int l = 3; l <= n; l++){
for(int i = 0; i <= n - l; i++){
for(int j = 0; j < m; j++){
int pre = (j == 0 ? 0 : pv[i][j - 1][l]);
pv[i][j][l] = pre + verti[i][j][i + l - 1];
}
}
}
for(int i = 0; i < n - 2; i++){
for(int j = 0; j < m - 2; j++){
for(int k = i + 2; k < n; k++){
for(int l = j + 2; l < m; l++){
int d1 = -ph[i][j][l - j + 1] + ph[k - 1][j][l - j + 1];
int d2 = -pv[i][j][k - i + 1] + pv[i][l - 1][k - i + 1];
if(d1 == k - i - 1 && d2 == l - j - 1)
ans++;
}
}
}
}
return ans;
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |