# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
234313 | UserIsUndefined | Rectangles (IOI19_rect) | C++14 | 5 ms | 512 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "rect.h"
#include <bits/stdc++.h>
int presum[3000][3000];
using namespace std;
long long count_rectangles(std::vector<std::vector<int> > a) {
int n = a.size();
int m = a[0].size();
long long ans = 0;
/*
for (int i = 1 ; i < n - 1 ; i++){
for (int j = 1 ; j < m - 1 ; j++){
int limitTol = n - 1;
int limitArad = m - 1;
for (int tol = 1 ; tol + i - 1 < limitTol ; tol++){
for (int arad = 1 ; arad + j - 1 < limitArad ; arad++){
int r1 = i, r2 = i + tol, c1 = j, c2 = j + arad;
bool ok = false;
for (int row = r1 ; row < r2 ; row++){
for (int cal = c1 ; cal < c2 ; cal++){
if (a[row][cal] < a[r1 - 1][cal] && a[row][cal] < a[row][c1 - 1] && a[row][cal] < a[r2][cal] && a[row][cal] < a[row][c2]){
continue;
}
else {
if (a[row][cal] >= a[r1 - 1][cal] || a[row][cal] >= a[row][c1 - 1])limitArad = cal;
ok = true;
break;
}
}
if (ok)break;
}
if (ok == false)ans++;
}
}
}
}
*/
vector<pair<int,int>> zeros;
for (int i = 0 ; i < n ; i++){
for (int j = 0 ; j < m ; j++){
if (j == 0)presum[i][j] = a[i][j];
else presum[i][j] = presum[i][j-1] + a[i][j];
}
}
for (int j = 0 ; j < m ; j++){
for (int i = 0 ; i < n ; i++){
if (i == 0)presum[i][j] = presum[i][j];
else presum[i][j] = presum[i-1][j] + presum[i][j];
}
}
for (int i = 1 ; i < n - 1 ; i++){
for (int j = 1 ; j < m - 1; j++){
if (a[i][j] == 0){
zeros.push_back({i,j});
}
}
}
for (int i = 0 ; i < zeros.size(); i++){
for (int j = i ; j < zeros.size() ; j++){
if (zeros[j].first < zeros[i].first || zeros[j].second < zeros[i].second)continue;
int big = presum[zeros[j].first][zeros[j].second];
int small = presum[zeros[i].first - 1][zeros[i].second - 1];
int first = presum[zeros[j].first][zeros[i].second - 1];
int second = presum[zeros[i].first-1][zeros[j].second];
// cout << "from " << "(" << zeros[i].first << "," << zeros[i].second << ") to (" << zeros[j].first << "," << zeros[j].second << ")" <<endl;
int sum = big - first - second + small;
// cout << "sum = " << sum << endl;
if (sum == 0)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... |