# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1067560 | MilosMilutinovic | Netrpeljivost (COI23_netrpeljivost) | C++14 | 461 ms | 58196 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<vector<int>> a(n, vector<int>(n));
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
cin >> a[i][j];
}
}
int lg = 0;
for (int p = 1; p < n; p *= 2, lg++) {}
const long long inf = (long long) 1e18;
vector<long long> dp(n);
for (int i = 0; i + 1 < n; i++) {
vector<long long> new_dp(n, inf);
for (int x = 0; x < n; x++) {
int bit;
for (int b = lg; b >= 0; b--) {
if ((i >> b & 1) != ((i + 1) >> b & 1)) {
bit = b;
break;
}
}
for (int xr = 0; xr < (1 << bit); xr++) {
int y = (x ^ xr);
new_dp[y] = min(new_dp[y], dp[x] + a[(i ^ x)][(i + 1) ^ y]);
}
}
swap(dp, new_dp);
}
cout << *min_element(dp.begin(), dp.end()) << '\n';
return 0;
}
컴파일 시 표준 에러 (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... |