# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
936315 | Trisanu_Das | Netrpeljivost (COI23_netrpeljivost) | C++17 | 467 ms | 90912 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2050;
const int INF = 0x3f3f3f3f;
int n, cst[N][N];
ll dp[N][N];
int main(){
scanf("%d", &n);
for(int i = 0;i < n;i++) for(int j = 0;j < n;j++) scanf("%d", &cst[i][j]);
for(int p = 1;p < n;p++) {
int ch = p & (-p);
for(int z = 0;z < n;z++) {
dp[p][z] = (ll)1e18;
int zz = (z ^ ch) & (~(ch - 1));
for(int t = zz;t < zz + ch;t++) dp[p][z] = min(dp[p][z], dp[p - 1][t] + cst[t][z]);
}
}
ll sol = (ll)1e18;
for(int i = 0;i < n;i++) sol = min(sol, dp[n - 1][i]);
printf("%lld\n", sol);
return 0;
}
Compilation message (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... |