Submission #758382

# Submission time Handle Problem Language Result Execution time Memory
758382 2023-06-14T14:28:41 Z Dan4Life Wall (IOI14_wall) C++17
8 / 100
3000 ms 13924 KB
#include "wall.h"
#include <bits/stdc++.h>
using namespace std;
const int mxN = (int)2e5+10;
int n, k, a[mxN];
array<int,2> seg[mxN*2];

void prop(int p, int l, int r){
    if(l==r) return; return;
    int mid = (l+r)/2; int rp = p+2*(mid-l+1);
    for(int i : {0,1}){
        seg[p+1][i]=seg[p][i];
        seg[rp][i]=seg[p][i];
    }
}

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){
        if(t==1){
            //if(seg[p][0]>=v) return;
            if(seg[p][1]<=v and l==r){ seg[p][0]=seg[p][1]=v; return; }
            if(l!=r) upd(i,j,t,v,p+1,l,mid), upd(i,j,t,v,rp,mid+1,r);
        }
        else{
            //if(seg[p][1]<=v) return;
            if(seg[p][0]>=v and l==r) {seg[p][0]=seg[p][1]=v; return; }
            if(l!=r) upd(i,j,t,v,p+1,l,mid), upd(i,j,t,v,rp,mid+1,r);
        }
        return;
    }
    upd(i,j,t,v,p+1,l,mid), upd(i,j,t,v,rp,mid+1,r);
    seg[p] = {min(seg[p+1][0],seg[rp][0]), max(seg[p+1][1],seg[rp][1])};
}

void query(int p=0, int l=0, int r=n-1){
    if(l==r){ a[l]=seg[p][0]; 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 < 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 prop(int, int, int)':
wall.cpp:9:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
    9 |     if(l==r) return; return;
      |     ^~
wall.cpp:9:22: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
    9 |     if(l==r) return; return;
      |                      ^~~~~~
wall.cpp: In function 'void upd(int, int, int, int, int, int, int)':
wall.cpp:18:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   18 |     if(i>r or j<l or i>j) return; prop(p,l,r);
      |     ^~
wall.cpp:18:35: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   18 |     if(i>r or j<l or i>j) return; prop(p,l,r);
      |                                   ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 316 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 4 ms 320 KB Output is correct
4 Correct 178 ms 660 KB Output is correct
5 Correct 168 ms 660 KB Output is correct
6 Correct 164 ms 648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 128 ms 13924 KB Output is correct
3 Execution timed out 3046 ms 7624 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 448 KB Output is correct
3 Correct 3 ms 340 KB Output is correct
4 Correct 181 ms 660 KB Output is correct
5 Correct 164 ms 652 KB Output is correct
6 Correct 165 ms 660 KB Output is correct
7 Correct 1 ms 312 KB Output is correct
8 Correct 127 ms 13872 KB Output is correct
9 Execution timed out 3047 ms 7560 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 4 ms 340 KB Output is correct
4 Correct 178 ms 656 KB Output is correct
5 Correct 161 ms 664 KB Output is correct
6 Correct 161 ms 648 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 126 ms 13860 KB Output is correct
9 Execution timed out 3048 ms 7596 KB Time limit exceeded
10 Halted 0 ms 0 KB -