제출 #235967

#제출 시각아이디문제언어결과실행 시간메모리
235967crossing0ver벽 (IOI14_wall)C++17
0 / 100
188 ms8348 KiB
#include<bits/stdc++.h> #include "wall.h" using namespace std; const int N = 2E6; int t[4*N][2],lazy[4*N][2],l,r,val;// min h, max h bool type; void push(int v,int tl,int tr) { if (lazy[v][0]) { if (lazy[v*2][0] < lazy[v][0] || !t[v*2][0]) lazy[v*2][0] = t[v*2][0] = lazy[v][0]; if (lazy[v*2|1][0] < lazy[v][0] || !t[v*2|1][0]) lazy[v*2|1][0] = t[v*2|1][0] = lazy[v][0]; lazy[v][0] = 0; if (lazy[v*2][0] > lazy[v*2][1] || !t[v*2][1]) t[v*2][1] = lazy[v*2][1] = lazy[v*2][0]; if (lazy[v*2|1][0] > lazy[v*2|1][1] || !t[v*2|1][1]) t[v*2|1][1] = lazy[v*2|1][1] = lazy[v*2|1][0]; } if (lazy[v][1]) { if (lazy[v*2][1] > lazy[v][1] || !t[v*2][1]) lazy[v*2][1] = t[v*2][1] = lazy[v][1]; if (lazy[v*2|1][1] > lazy[v][1] != t[v*2|1][1]) lazy[v*2|1][1] = t[v*2|1][1] = lazy[v][1]; if (lazy[v*2][0] > lazy[v*2][1] || !t[v*2][0]) t[v*2][0] = lazy[v*2][0] = lazy[v*2][1]; if (lazy[v*2|1][0] > lazy[v*2|1][1] || !t[v*2|1][0]) t[v*2|1][0] = lazy[v*2|1][0] = lazy[v*2|1][1]; lazy[v][1] = 0; } } void upd (int v,int tl,int tr) { if (l > tr || r < tl) return; if (tl >= l && tr <= r) { if (type == 0) { if (t[v][0] >= val) return; t[v][0] = val; lazy[v][0] = val; if (t[v][1] < val) { t[v][1] = lazy[v][1] = val; } } else { if (t[v][1] <= val && t[v][1]) return; t[v][1] = val; lazy[v][1] = val; if (t[v][0] > val) { t[v][0] = lazy[v][0] = val; } } return; } push (v,tl,tr); int tm = (tl + tr)/2; upd (v*2,tl,tm); upd (v*2|1,tm+1,tr); } int A[N]; void get (int v,int tl,int tr) { if (tl == tr) A[tl] = t[v][0]; else { int tm = (tl + tr)/2; push(v,tl,tr); get(v*2,tl,tm); get(v*2+1,tm+1,tr); } } void buildWall(int n, int k, int op[], int left[], int right[],int height[], int finalHeight[]) { for (int i = 0; i < k; i++) { type = op[i] - 1; l = left[i]; r = right[i]; val = height[i] + 1; upd (1,0,n-1); } get(1,0,n-1); for (int i = 0;i < n; i++) finalHeight[i] = max (A[i] - 1,0); }

컴파일 시 표준 에러 (stderr) 메시지

wall.cpp: In function 'void push(int, int, int)':
wall.cpp:21:22: warning: suggest parentheses around comparison in operand of '!=' [-Wparentheses]
   if (lazy[v*2|1][1] > lazy[v][1] != t[v*2|1][1]) 
       ~~~~~~~~~~~~~~~^~~~~~~~~~~~
wall.cpp:21:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   if (lazy[v*2|1][1] > lazy[v][1] != t[v*2|1][1]) 
   ^~
wall.cpp:23:4: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
    if (lazy[v*2][0] > lazy[v*2][1] || !t[v*2][0]) t[v*2][0] = lazy[v*2][0] = lazy[v*2][1];
    ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...