이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "rect.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> tree;
void update(int v, int rl, int rr, int pos, int x) {
if (rl == rr) {
tree[v] = x;
return;
}
int rm = (rl + rr)/2;
if (pos <= rm) update(v*2, rl, rm, pos, x);
else update(v*2+1, rm+1, rr, pos, x);
tree[v] = max(tree[v*2], tree[v*2+1]);
}
int querry(int v, int rl, int rr, int ql, int qr) {
if (ql > qr) return 0;
if (rl == ql && rr == qr) {
return tree[v];
}
int rm = (rl + rr) / 2;
return max(querry(v*2, rl, rm, ql, min(qr, rm)), querry(v*2+1, rm+1, rr, max(rm+1, ql), qr));
}
long long count_rectangles(std::vector<std::vector<int> > a) {
vector<bool> topBottom;
tree.assign(a[1].size()*4, 0);
int res = 0;
for (int i = 0; i<a[1].size(); i++) {
topBottom.push_back(a[1][i] < a[0][i] && a[1][i] < a[2][i]);
update(1, 0, a[1].size()-1, i, a[1][i]);
}
for (int i = 1; i<a[1].size()-1; i++) {
for (int j = i; j<a[1].size()-1; j++) {
if (querry(1, 0, a[1].size()-1, i, j) < min(a[1][i-1], a[1][j+1])) { res++;}
}
}
return res;
}
컴파일 시 표준 에러 (stderr) 메시지
rect.cpp: In function 'long long int count_rectangles(std::vector<std::vector<int> >)':
rect.cpp:43:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
43 | for (int i = 0; i<a[1].size(); i++) {
| ~^~~~~~~~~~~~
rect.cpp:48:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
48 | for (int i = 1; i<a[1].size()-1; i++) {
| ~^~~~~~~~~~~~~~
rect.cpp:49:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
49 | for (int j = i; j<a[1].size()-1; j++) {
| ~^~~~~~~~~~~~~~
# | 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... |