제출 #408108

#제출 시각아이디문제언어결과실행 시간메모리
408108mshandilya벽 (IOI14_wall)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "wall.h" using namespace std; void add(std::vector<int>& ST, std::vector<int>& lazy, int update, int rbeg, int rend, int beg, int end, int node) { if(rbeg>rend) return; if(lazy[node-1]!=-1) { ST[node-1] = lazy[node-1]; lazy[2*node-1] = lazy[node-1]; lazy[2*node] = lazy[node-1]; lazy[node-1] = -1; } if(rbeg==beg and rend==end) { ST[node-1] = max(update, ST[node-1]); if(lazy[2*node-1]==-1) lazy[2*node-1] = max(update, ST[2*node-1]); else lazy[2*node-1] = max(update, lazy[2*node-1]); if(lazy[2*node]==-1) lazy[2*node] = max(update, ST[2*node]); else lazy[2*node] = max(update, lazy[2*node]); return; } int mid = (beg+end)/2; add(ST, lazy, update, rbeg, min(mid, rend), beg, mid, 2*node); add(ST, lazy, update, max(rbeg, mid+1), rend, mid+1, end, 2*node+1); return; } void remov(std::vector<int>& ST, std::vector<int>& lazy, int update, int rbeg, int rend, int beg, int end, int node) { if(rbeg>rend) return; if(lazy[node-1]!=-1) { ST[node-1] = lazy[node-1]; lazy[2*node-1] = lazy[node-1]; lazy[2*node] = lazy[node-1]; lazy[node-1] = -1; } if(rbeg==beg and rend==end) { ST[node-1] = min(update, ST[node-1]); if(lazy[2*node-1]==-1) lazy[2*node-1] = min(update, ST[2*node-1]); else lazy[2*node-1] = min(update, lazy[2*node-1]); if(lazy[2*node]==-1) lazy[2*node] = min(update, ST[2*node]); else lazy[2*node] = min(update, lazy[2*node]); return; } int mid = (beg+end)/2; remov(ST, lazy, update, rbeg, min(mid, rend), beg, mid, 2*node); remov(ST, lazy, update, max(rbeg, mid+1), rend, mid+1, end, 2*node+1); return; } int retrieve(std::vector<int>& ST, std::vector<int>& lazy, int find, int beg, int end, int node) { if(lazy[node-1]!=-1) { ST[node-1] = lazy[node-1]; lazy[2*node-1] = lazy[node-1]; lazy[2*node] = lazy[node-1]; lazy[node-1] = -1; } if(beg==end) return ST[node-1]; int mid = (beg+end)/2; if(find<=mid) return retrieve(ST, lazy, find, beg, mid, 2*node); else return retrieve(ST, lazy, find, mid+1, end, 2*node+1); } void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){ int st_size = 1; while(st_size<n) st_size<<=1; std::vector<int> ST(2*st_size-1, 0), lazy(2*st_size-1, -1); for (int i = 0; i<k; ++i) { if(op[i]==1) add(ST, lazy, height[i], left[i], right[i], 0, st_size-1, 1); else remov(ST, lazy, height[i], left[i], right[i], 0, st_size-1, 1); } for(int i = 0; i<n; i++) finalHeight[i] = retrieve(ST, lazy, i, 0, st_size-1, 1); return; } int main() { int n, k; cin>>n>>k; int op[k], left[k], right[k], height[k], finalHeight[n]; for(int i = 0; i<k; i++) cin>>op[i]>>left[i]>>right[i]>>height[i]; buildWall(n, k, op, left, right, height, finalHeight); for(int i = 0; i<n; i++) cout<<finalHeight[i]<<" "; cout<<endl; return 0; }

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

/usr/bin/ld: /tmp/ccfgZghJ.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc8GivUF.o:wall.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status