//Oh? You're Approaching Me?
#include <bits/stdc++.h>
using namespace std;
//
#define int long long
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
// #pragma GCC optimize("O3,unroll-loops")
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define F first
#define S second
#define SZ(x) ll((x).size())
#define all(x) (x).begin(), (x).end()
#define cl clear
#define endl '\n'
#define deb(x) cerr << #x << " = " << x << '\n'
#define dokme(x) {cout << x << endl; return;}
#define wtf cout << "[ahaaaaaaaaaaaaaaaa]" << endl;
const int maxn = 3000 + 10;
const int mod = 998244353;
const int inf = 1e18 + 5;
const int LOG = 31;
#define mid ((l + r) / 2)
#define lc (id * 2)
#define rc (lc + 1)
//g++ main.cpp -o main && main.exe
int n, C[maxn][maxn], dp[maxn][maxn];
signed main() {
cin >> n;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
cin >> C[i][j];
}
}
for (int lv = 1; lv < n; lv++) {
int ln = (lv & (-lv));
for (int i = 0; i < n; i++) {
dp[lv][i] = inf;
int l = ((i ^ ln) & (~(ln - 1)));
int r = l + ln;
for (int j = l; j < r; j++) {
dp[lv][i] = min(dp[lv][i], dp[lv - 1][j] + C[i][j]);
}
}
}
ll ans = inf;
for (int i = 0; i < n; i++)
ans = min(ans, dp[n - 1][i]);
cout << ans << '\n';
}
| # | 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... |