제출 #88595

#제출 시각아이디문제언어결과실행 시간메모리
88595amiratouRoller Coaster Railroad (IOI16_railroad)C++14
0 / 100
250 ms16132 KiB
#include <bits/stdc++.h> using namespace std; #define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0) #define debug(x) cerr << " - " << #x << ": " << x << endl; #define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl; #define sep() cerr << "--------------------" << endl; #define all(x) (x).begin(),(x).end() #define sz(x) (ll)x.size() #define fi first #define se second #define ll long long #define ii pair<int,int> #define v vector<int> #define vv vector<vector<int> > #define pb push_back #define INF 15 using namespace std; set<pair<ll,ll> > myset; long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) { int n = (int) s.size(); ll maxi,maxval=0,mini,minval=INT_MAX; for (int i = 0; i < n; ++i) { myset.insert({s[i],i}); if(minval>s[i]){ minval=s[i]; mini=i; } if(maxval<t[i]){ maxval=t[i]; maxi=i; } } if(maxi==mini){ auto temp=myset.begin(); temp++; mini=temp->se; } myset.erase(myset.find({s[mini],mini})); myset.erase(myset.find({s[maxi],maxi})); int curr=t[mini]; while(!myset.empty()){ //debug(curr); auto search=myset.lower_bound({curr,0}); if(search==myset.end())return INF; auto it=myset.end(); it--; if(search!=it&&search->fi!=curr) search++; curr=t[search->se]; myset.erase(search); } //debug(curr); if(curr<=s[maxi]) return 0; return INF; }

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

railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:54:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
     if(curr<=s[maxi])
     ^~
railroad.cpp:56:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
  return INF;
  ^~~~~~
railroad.cpp:34:5: warning: 'mini' may be used uninitialized in this function [-Wmaybe-uninitialized]
     if(maxi==mini){
     ^~
railroad.cpp:34:5: warning: 'maxi' may be used uninitialized in this function [-Wmaybe-uninitialized]
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...