Submission #758404

# Submission time Handle Problem Language Result Execution time Memory
758404 2023-06-14T15:03:27 Z Dan4Life Wall (IOI14_wall) C++17
0 / 100
184 ms 8072 KB
#include "wall.h"
#include <bits/stdc++.h>
using namespace std;
const int mxN = (int)2e5+10;
const int INF = (int)1e9+10;
int n, k, a[mxN];
array<int,2> seg[mxN*2];
//maximize then minimize
void prop(int p, int l, int r){
    if(l==r) return;
    int mid = (l+r)/2; int rp = p+2*(mid-l+1);
    for(int i : {0,1}){
        seg[p+1][i] = min(max(seg[p+1][i],seg[p][0]),seg[p][1]);
        seg[rp][i] = min(max(seg[rp][i],seg[p][0]),seg[p][1]);
    }
    seg[p] = {0,INF};
}

void upd(int i, int j, int t, int v, int p=0, int l=0, int r=n-1){
    if(i>r or j<l or i>j) return; prop(p,l,r);
    int mid = (l+r)/2; int rp = p+2*(mid-l+1);
    if(i<=l and r<=j){ seg[p][t!=1]=v; return; }
    upd(i,j,t,v,p+1,l,mid), upd(i,j,t,v,rp,mid+1,r);
}

void query(int p=0, int l=0, int r=n-1){
    if(l==r){ a[l]=min(seg[p][0],seg[p][1]); return; } prop(p,l,r);
    int mid = (l+r)/2; int rp = p+2*(mid-l+1);
    query(p+1,l,mid), query(rp,mid+1,r);
}

void buildWall(int N, int k, int o[], int l[], int r[], int h[], int ans[]){
    n = N;
    for(int i = 0; i <= 2*n; i++) seg[i]={0,INF};
    for(int i = 0; i < k; i++) upd(l[i],r[i],o[i],h[i]);
    query(); for(int i = 0; i < n; i++) ans[i]=a[i];
}

Compilation message

wall.cpp: In function 'void upd(int, int, int, int, int, int, int)':
wall.cpp:20:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   20 |     if(i>r or j<l or i>j) return; prop(p,l,r);
      |     ^~
wall.cpp:20:35: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   20 |     if(i>r or j<l or i>j) return; prop(p,l,r);
      |                                   ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 2 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 184 ms 8072 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 2 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 4 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -