# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
807478 | happypotato | Roller Coaster Railroad (IOI16_railroad) | C++17 | 280 ms | 524288 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "railroad.h"
#include <bits/stdc++.h>
using namespace std;
#define int long long
vector<int> s, t;
int n;
int BruteDP() {
int dp[(1 << n)][n];
for (int conf = 0; conf < (1 << n); conf++) {
for (int i = 0; i < n; i++) {
dp[conf][i] = (conf == (1 << i) ? 0 : 1e18);
}
}
for (int bit = 2; bit <= n; bit++) {
for (int conf = 0; conf < (1 << n); conf++) {
if (__builtin_popcountll(conf) != bit) continue;
for (int i = 0; i < n; i++) {
if (conf & (1 << i)) {
for (int j = 0; j < n; j++) {
if (!bool(conf & (1 << j)) || i == j) continue;
// cerr << "UPDATE " << conf << ' ' << i << ' ' << j << ' ' << dp[conf ^ (1 << i)][j] << ' ';
// cerr << t[j] << ' ' << s[i] << endl;
dp[conf][i] = min(dp[conf][i], dp[conf ^ (1 << i)][j] + max(0LL, t[j] - s[i]));
}
}
}
}
}
// for (int i = 0; i < (1 << n); i++) {
// for (int j = 0; j < n; j++) cerr << dp[i][j] << ' ';
// cerr << endl;
// }
int ans = 1e18;
for (int i = 0; i < n; i++) ans = min(ans, dp[(1 << n) - 1][i]);
return ans;
}
long long plan_roller_coaster(vector<int32_t> S, vector<int32_t> T) {
n = S.size(); s.resize(n); t.resize(n);
for (int i = 0; i < n; i++) {
s[i] = S[i]; t[i] = T[i];
}
// for (int i = 0; i < n; i++) cerr << s[i] << ' '; cerr << endl;
// for (int i = 0; i < n; i++) cerr << t[i] << ' '; cerr << endl;
if (n <= 16) return BruteDP();
}
#undef int
컴파일 시 표준 에러 (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... |