# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
598406 | jk410 | Building 4 (JOI20_building4) | C++17 | 339 ms | 139280 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 <bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
const int INF=1e9;
struct itv{
int l,r;
};
itv operator+(itv a,itv b){
return {min(a.l,b.l),max(a.r,b.r)};
}
int N;
int A[1000001],B[1000001];
itv DP[1000001][2];
string Ans;
itv dp(int i,int j){
itv &ret=DP[i][j];
if (ret.l!=-1||ret.r!=-1)
return ret;
ret={INF,-1};
int tmp=(j?B[i]:A[i]);
if (A[i-1]<=tmp&&(dp(i-1,0).l!=INF||dp(i-1,0).r!=-1))
ret=ret+dp(i-1,0);
if (B[i-1]<=tmp&&(dp(i-1,1).l!=INF||dp(i-1,1).r!=-1))
ret=ret+dp(i-1,1);
if (ret.l==INF&&ret.r==-1)
return ret;
if (!j){
ret.l++;
ret.r++;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |