Submission #954560

#TimeUsernameProblemLanguageResultExecution timeMemory
954560becaidoNetrpeljivost (COI23_netrpeljivost)C++17
100 / 100
403 ms58468 KiB
#pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx,popcnt,sse4,abm") #include <bits/stdc++.h> using namespace std; #ifdef WAIMAI #define debug(HEHE...) cout << "[" << #HEHE << "] : ", dout(HEHE) void dout() {cout << '\n';} template<typename T, typename...U> void dout(T t, U...u) {cout << t << (sizeof...(u) ? ", " : ""), dout(u...);} #else #define debug(...) 7122 #endif #define ll long long #define Waimai ios::sync_with_stdio(false), cin.tie(0) #define FOR(x,a,b) for (int x = a, I = b; x <= I; x++) #define pb emplace_back #define F first #define S second const ll INF = 1e18; const int SIZE = 2100; int n; int a[SIZE][SIZE]; ll dp[2][SIZE]; void solve() { cin >> n; FOR (i, 0, n - 1) FOR (j, 0, n - 1) cin >> a[i][j]; FOR (i, 1, n - 1) { int f = (i + 1) & 1, b = i & -i; fill(dp[f], dp[f] + n, INF); FOR (j, 0, n - 1) { int s = (j ^ b) & (~(b - 1)); FOR (k, s, s + b - 1) dp[f][k] = min(dp[f][k], dp[!f][j] + a[j][k]); } } cout << *min_element(dp[n & 1], dp[n & 1] + n) << '\n'; } int main() { Waimai; solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...