제출 #124699

#제출 시각아이디문제언어결과실행 시간메모리
124699zubecRoller Coaster Railroad (IOI16_railroad)C++14
0 / 100
331 ms45304 KiB
#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()); 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); } } 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:34:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < s.size(); i++){
                     ~~^~~~~~~~~~
railroad.cpp:42:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < zhat.size(); i++){
                     ~~^~~~~~~~~~~~~
railroad.cpp:51:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < zhat.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...