제출 #349336

#제출 시각아이디문제언어결과실행 시간메모리
349336David_MWall (IOI14_wall)C++14
컴파일 에러
0 ms0 KiB
#include "wall.h" #include <bits/stdc++.h> #define pb push_back using namespace std; const int INF=1e9+2021; struct uwu{int type, height, time; uwu (int x, int y, int z){time=z,type=x,height=y;} }; vector<uwu> v[1<<21]; int T[2][1<<21], M[2], K; void build (int x=1, int l=0, int r=K){ if(l==r){ T[1][x]=(!!l)*INF; return; } T[1][x]=min(T[1][x<<1], T[1][x<<1|1]); } void upd(uwu a, int x=1, int l=0, int r=K){ if(l==r){ T[a.type][x]=a.height; return; } int mid=l+r>>1; if(a.time<mid) upd(a, x<<1, l, mid); else upd(a, x<<1|1, mid+1, r); T[0][x]=max(T[0][x<<1], T[0][x<<1|1]); T[1][x]=min(T[1][x<<1], T[1][x<<1|1]); } void get(int id, int x=1, int l=0, int r=K){ if(l==r){finalHeight[id]=(T[0][x]==M[0])?M[1]:M[0]; return;} // int m[]={max(M[0], T[0][x<<1|1]), min(M[1], T[1][x<<1|1])}, mid=l+r>>1; int m[2], mid=l+r>>1; m[0]=max(M[0], T[0][x<<1|1]); m[1]=min(M[1], T[1][x<<1|1]); if(m[1]>m[0])M[0]=m[0], M[1]=m[1], get(id, x<<1, l, mid); else get(id, x<<1|1, mid+1, r); } void buildWall(int n, int k, int op[], int left[], int right[],int height[], int finalHeight[]){ build(); K=k; for(int i=0; i<k; i++){ op[i]--; v[left[i]].pb({i+1, op[i], height[i]}); v[right[i]+1].pb({i+1, op[i], op[i]==1?0:INF}); } for (int i=0; i<n; i++){ for (int j=0; j<v[i].size(); j++) upd(v[i][j]); M[0]=0; M[1]=INF; get(i); } }

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

wall.cpp: In function 'void upd(uwu, int, int, int)':
wall.cpp:17:11: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   17 |  int mid=l+r>>1;
      |          ~^~
wall.cpp: In function 'void get(int, int, int, int)':
wall.cpp:26:11: error: 'finalHeight' was not declared in this scope
   26 |  if(l==r){finalHeight[id]=(T[0][x]==M[0])?M[1]:M[0]; return;}
      |           ^~~~~~~~~~~
wall.cpp:28:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   28 |  int m[2], mid=l+r>>1;
      |                ~^~
wall.cpp: In function 'void buildWall(int, int, int*, int*, int*, int*, int*)':
wall.cpp:46:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<uwu>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |   for (int j=0; j<v[i].size(); j++) upd(v[i][j]);
      |                 ~^~~~~~~~~~~~