이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "meetings.h"
//#include "grader.cpp"
#include<bits/stdc++.h>
using namespace std;
int sparse[750001][21],LOG[750001];
int query(int L,int R){
if(L>R)
return 0;
int Q=LOG[R-L+1];
return max(sparse[L][Q],sparse[R-(1<<Q)+1][Q]);
}
int BS(int L,int R){
int LL=L,RR=R,CUR=query(L,L),mid,LAST=LL;
while(LL<=RR){
mid=(LL+RR)/2;
if((mid-L)+CUR==query(L,mid))
LAST=max(LAST,mid),LL=mid+1;
else
RR=mid-1;
}
return max(query(L,LAST)-max(CUR-1,0),query(LAST+1,R));
}
vector<long long>minimum_costs(vector<int>H,vector<int>L,vector<int>R){
vector<long long>ANS;
LOG[1]=0;
for(int i=2;i<=750000;i++)
LOG[i]=LOG[i/2];
sparse[0][0]=((H[0]==1)?1:0);
for(int i=1;i<H.size();i++)
sparse[i][0]=((H[i]==1)?sparse[i-1][0]+1:0);
for(int l=1;l<21;l++){
for(int i=0;i + (1 << l)<=H.size();i++){
sparse[i][l]=max(sparse[i][l-1],sparse[i+(1<<(l-1))][l-1]);
}
}
//for(int i=0;i<L.size();i++)
//cout<<L[i]<<' '<<R[i]<<": "<<(R[i]-L[i]+1)*2-BS(L[i],R[i])<<endl;
for(int i=0;i<L.size();i++)
ANS.push_back((R[i]-L[i]+1)*2-BS(L[i],R[i]));
return ANS;
}
컴파일 시 표준 에러 (stderr) 메시지
meetings.cpp: In function 'std::vector<long long int> minimum_costs(std::vector<int>, std::vector<int>, std::vector<int>)':
meetings.cpp:29:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
29 | for(int i=1;i<H.size();i++)
| ~^~~~~~~~~
meetings.cpp:32:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | for(int i=0;i + (1 << l)<=H.size();i++){
| ~~~~~~~~~~~~^~~~~~~~~~
meetings.cpp:38:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
38 | for(int i=0;i<L.size();i++)
| ~^~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |