# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
598098 | yutabi | Rectangles (IOI19_rect) | C++14 | 1 ms | 340 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "rect.h"
#include <bits/stdc++.h>
using namespace std;
long long count_rectangles(std::vector<std::vector<int> > a)
{
if(a.size()<3)
{
return 0;
}
vector <bool> valid(50000,1);
int maxi=0;
for(int i=0;i<a[1].size();i++)
{
if(a[1][i]>=a[0][i] || a[1][i]>=a[2][i])
{
valid[i]=0;
maxi=a[1][i];
}
if(a[1][i]>=maxi)
{
maxi=a[1][i];
valid[i]=0;
}
}
maxi=0;
for(int i=a[1].size()-1;i>=0;i--)
{
if(a[1][i]>=a[0][i] || a[1][i]>=a[2][i])
{
valid[i]=0;
maxi=a[1][i];
}
if(a[1][i]>=maxi)
{
maxi=a[1][i];
valid[i]=0;
}
}
vector <int> s;
int res=0;
for(int i=0;i<a[1].size();i++)
{
while(s.size() && a[1][i]>s.back())
{
s.pop_back();
}
if(valid[i]==1)
{
res++;
if(s.size() && s.back()==a[1][i])
{
res--;
}
}
s.push_back(a[1][i]);
}
return res;
}
Compilation message (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... |