제출 #205969

#제출 시각아이디문제언어결과실행 시간메모리
205969HungAnhGoldIBO2020Roller Coaster Railroad (IOI16_railroad)C++14
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> #define coor cac #define int long long using namespace std; const int N=4e5+2; const int inf=1e9+7; vector<int> coor; int head[N],cnt[N]; priority_queue<pair<int,pair<int,int> > > lis; int findd(int x){ if(head[x]<0){ return x; } int y=findd(head[x]); head[x]=y; return y; } void unionn(int x,int y){ x=findd(x),y=findd(y); head[x]+=head[y]; head[y]=x; } bool samee(int x,int y){ return findd(x)==findd(y); } int plan_roller_coaster(vector<int> s,vector<int> t){ s.push_back(inf); t.push_back(1); int n=s.size(),i,j,k,l,r,ans=0; for(i=0;i<n;i++){ coor.push_back(s[i]); coor.push_back(t[i]); } sort(coor.begin(),coor.end()); coor.erase(unique(coor.begin(),coor.end()),coor.end()); for(i=0;i<coor.size();i++){ head[i+1]=-1; } for(i=0;i<n;i++){ l=lower_bound(coor.begin(),coor.end(),s[i])-coor.begin()+1; r=lower_bound(coor.begin(),coor.end(),t[i])-coor.begin()+1; cnt[l]++; cnt[r]--; if(!samee(l,r)){ unionn(l,r); } } for(i=1;i<=coor.size();i++){ cnt[i]+=cnt[i-1]; if(i==coor.size()){ assert(cnt[i]==0); } if(cnt[i]!=0){ if(!samee(i,i+1)){ unionn(i,i+1); } ans+=max(0ll,cnt[i])*(coor[i-1]-coor[i-2]); } } for(i=1;i<coor.size();i++){ if(!samee(i,i+1)){ lis.push({-(coor[i]-coor[i-1]),{i,i+1}}); } } while(lis.size()){ i=lis.top().first; j=lis.top().second.first; k=lis.top().second.second; lis.pop(); if(samee(j,k)){ continue; } unionn(j,k); ans-=i; } return ans; } //signed main(){ // ios::sync_with_stdio(0); // cin.tie(0); // cout<<plan_roller_coaster({1, 4, 5, 6}, {7, 3, 8, 6}); //}

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

railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<long long int>, std::vector<long long int>)':
railroad.cpp:36:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(i=0;i<coor.size();i++){
          ~^~~~~~~~~~~~
railroad.cpp:48:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(i=1;i<=coor.size();i++){
          ~^~~~~~~~~~~~~
railroad.cpp:50:7: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(i==coor.size()){
      ~^~~~~~~~~~~~~
railroad.cpp:60:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(i=1;i<coor.size();i++){
          ~^~~~~~~~~~~~
/tmp/ccsiIHfb.o: In function `main':
grader.cpp:(.text.startup+0xe3): undefined reference to `plan_roller_coaster(std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status