제출 #73147

#제출 시각아이디문제언어결과실행 시간메모리
73147KmcodeRoller Coaster Railroad (IOI16_railroad)C++14
0 / 100
1002 ms525312 KiB
#include<bits/stdc++.h> using namespace std; //#include "railroad.h" map<int,long long int> mp; #define MAX 200002 int belong[MAX]; inline int root(int b){ if(belong[b]==-1){ return b; } return belong[b]=root(belong[b]); } void merge(int a,int b){ a=root(a); b=root(b); if(a==b)return; belong[a]=b; return; } map<int,int> idx; long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) { t.push_back(-1); s.push_back(INT_MAX-3); for(int i=0;i<s.size();i++){ mp[s[i]]++; mp[t[i]]--; idx[s[i]]=0; idx[t[i]]=0; } int ii=-1; for(auto &it:idx){ ii++; it.second=ii; } for(int i=0;i<s.size();i++){ merge(idx[s[i]],idx[t[i]]); } long long int sum=0; for(auto &it:mp){ if(sum)merge(idx[it.first],idx[it.first]-1); long long int add=sum; sum-=it.second; it.second-=add; it.second+=sum; //cout<<add<<" "<<sum<<endl; if(sum<0){ return 111; } } set<int> ss; for(int i=0;i<mp.size();i++){ ss.insert(root(i)); } if(ss.size()>1){ return 333; } for(auto it:mp){ if(it.second!=0){ return 222; } } return 0; }

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

railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:27:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<s.size();i++){
                 ~^~~~~~~~~
railroad.cpp:38:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<s.size();i++){
              ~^~~~~~~~~
railroad.cpp:54:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<mp.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...