이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "railroad.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int N = 400100;
vector <int> g[N];
bool used[N];
void dfs(int v){
used[v] = 1;
for (int i = 0; i < g[v].size(); i++){
int to = g[v][i];
if (!used[to])
dfs(to);
}
}
int dp[N];
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) {
vector <int> zhat;
s.push_back(1e9);
t.push_back(1);
for (int i = 0; i < s.size(); i++){
zhat.push_back(s[i]);
zhat.push_back(t[i]);
}
sort(zhat.begin(), zhat.end());
zhat.erase(unique(zhat.begin(), zhat.end()), zhat.end());
memset(dp, 0, sizeof(dp));
for (int i = 0; i < s.size(); i++){
int ss = lower_bound(zhat.begin(), zhat.end(), s[i])-zhat.begin();
int tt = lower_bound(zhat.begin(), zhat.end(), t[i])-zhat.begin();
--dp[ss];
++dp[tt];
g[ss].push_back(tt);
}
int cur = 0;
for (int i = 0; i < zhat.size(); i++){
cur += dp[i];
if (cur < 0)
return 123;
if (cur > 0 && i > 0){
g[i-1].push_back(i);
}
}
memset(used, 0, sizeof(used));
dfs(0);
for (int i = 0; i < zhat.size(); i++)
if (!used[i])
return 123;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
railroad.cpp: In function 'void dfs(int)':
railroad.cpp:15:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < g[v].size(); i++){
~~^~~~~~~~~~~~~
railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:28:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < s.size(); i++){
~~^~~~~~~~~~
railroad.cpp:35:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < s.size(); i++){
~~^~~~~~~~~~
railroad.cpp:43:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < zhat.size(); i++){
~~^~~~~~~~~~~~~
railroad.cpp:53:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < zhat.size(); i++)
~~^~~~~~~~~~~~~
# | 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... |