이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "railroad.h"
#include <bits/stdc++.h>
#define Loop(x,l,r) for (ll x = (l); x < (ll)(r); ++x)
#define LoopR(x,l,r) for (ll x = (r)-1; x >= (ll)(l); --x)
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll , ll > pll;
using namespace std;
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t)
{
int n = s.size();
set<pii> S;
Loop (i,0,n)
S.insert({s[i], i});
int cnt = 0;
int ds;
vector<pii> vec;
while (S.size()) {
int i = S.begin()->second;
int is = s[i], it = t[i];
S.erase(S.begin());
while (is < it) {
auto p = S.lower_bound(pii{it, INT_MIN});
if (p == S.end()) {
++cnt;
ds = is;
break;
}
int j = p->second;
S.erase(p);
it = t[j];
vec.push_back({it, is});
}
}
if (cnt > 1)
return 1;
if (cnt == 0)
return 0;
sort(vec.begin(), vec.end());
for (auto [x, y] : vec) {
if (x > ds)
return 1;
ds = max(ds, y);
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:17:6: warning: 'ds' may be used uninitialized in this function [-Wmaybe-uninitialized]
17 | int ds;
| ^~| # | 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... |