이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "rect.h"
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<int, int> pii;
typedef pair<ld, ld> pld;
int n, m;
ll solven3(vector<std::vector<int> > a){
vector<int> bad;
for(int i = 0; i < m; ++i)
if(a[1][i] >= a[0][i] || a[1][i] >= a[2][i]){
bad.pb(i);
}
vector<pii> vec;
ll ans = 0;
for(int i = m-1; i >= 0; --i){
while(vec.size()){
int idx1 = upper_bound(all(bad), i)-bad.begin();
int idx2 = upper_bound(all(bad), vec.back().ss)-bad.begin()-1;
if(idx1 > idx2 && vec.back().ss != i+1)
++ans;
if(vec.back().ff > a[1][i])
break;
vec.pop_back();
}
vec.pb({a[1][i], i});
}
return ans;
}
long long count_rectangles(vector<std::vector<int> > a) {
n = a.size();
m = a[0].size();
return solven3(a);
}
# | 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... |