제출 #412894

#제출 시각아이디문제언어결과실행 시간메모리
412894Ahmadsm2005모임들 (IOI18_meetings)C++14
17 / 100
130 ms16956 KiB
#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]+1; 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-1))<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; //cout<<query(L[0],R[0])<<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-1))<H.size();i++){
      |             ~~~~~~~~~~~~^~~~~~~~~
meetings.cpp:39:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 | for(int i=0;i<L.size();i++)
      |             ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...