# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
786742 | mindiyak | Roller Coaster Railroad (IOI16_railroad) | C++14 | 197 ms | 524288 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "railroad.h"
#include <iostream>
#include <unordered_set>
#define ll long long
using namespace std;
const int MAXN = (2*1e5)+2;
// const int MAXN = 100;
vector<vector<int>> costTable(MAXN,vector<int>(MAXN,0));
long long ans = 1e18;
void dfs(int n,int pos,unordered_set<int> visited,ll cost){
if(cost >= ans){
return;
}
visited.insert(pos);
if(visited.size() == n){
ans = min(ans,cost);
return;
}
for(int i=0;i<n;i++){
if(visited.count(i) == 0){
dfs(n,i,visited,cost+costTable[pos][i]);
}
}
}
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) {
int n = (int) s.size();
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(j==i){
costTable[i][j] = 0;
}else{
// cout << i << " " << j << " " << t[i] << " " << s[i] << " " << t[j] << " " << s[j] << endl;
costTable[i][j] = max(0,t[i]-s[j]);
}
}
}
// cout << endl;
// for(int i=0;i<n;i++){
// for(int j=0;j<n;j++){
// cout << costTable[i][j] << " ";
// }cout << endl;
// }
unordered_set<int> visited;
for(int i=0;i<n;i++){
dfs(n,i,visited,0);
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |