Submission #446145

#TimeUsernameProblemLanguageResultExecution timeMemory
446145JerryLiu06Raisins (IOI09_raisins)C++17
100 / 100
201 ms30612 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using db = double; using str = string; using pi = pair<int, int>; using pl = pair<ll, ll>; using pd = pair<db, db>; using vi = vector<int>; using vb = vector<bool>; using vl = vector<ll>; using vd = vector<db>; using vs = vector<str>; using vpi = vector<pi>; using vpl = vector<pl>; using vpd = vector<pd>; #define mp make_pair #define f first #define s second #define sz(x) (int)(x).size() #define bg(x) begin(x) #define all(x) bg(x), end(x) #define sor(x) sort(all(x)) #define rsz resize #define ins insert #define ft front() #define bk back() #define pb push_back #define pf push_front #define lb lower_bound #define ub upper_bound #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define F0R(i, a) FOR(i, 0, a) #define ROF(i, a, b) for (int i = (b) - 1; i >= (a); i--) #define R0F(i, a) ROF(i, 0, a) #define EACH(a, x) for (auto& a : x) ll cdiv(ll a, ll b) { return a / b + ((a ^ b) > 0 && a % b); } ll fdiv(ll a, ll b) { return a / b - ((a ^ b) < 0 && a % b); } template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; } template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; } template<class T> void remDup(vector<T>& v) { sor(v); v.erase(unique(all(v)), v.end()); } const int MOD = 1e9 + 7; const int MX = 55; const ll INF = 1e18; int N, M; int pref[MX][MX]; ll DP[MX][MX][MX][MX]; int query(int X1, int X2, int Y1, int Y2) { return pref[X2][Y2] - pref[X1 - 1][Y2] - pref[X2][Y1 - 1] + pref[X1 - 1][Y1 - 1]; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> N >> M; FOR(i, 1, N + 1) FOR(j, 1, M + 1) { cin >> pref[i][j]; pref[i][j] += pref[i - 1][j] + pref[i][j - 1] - pref[i - 1][j - 1]; } ROF(X1, 1, N + 1) FOR(X2, X1, N + 1) ROF(Y1, 1, M + 1) FOR(Y2, Y1, M + 1) { if (X1 == X2 && Y1 == Y2) continue; DP[X1][X2][Y1][Y2] = query(X1, X2, Y1, Y2); ll MN = INF; FOR(X, X1, X2) ckmin(MN, DP[X1][X][Y1][Y2] + DP[X + 1][X2][Y1][Y2]); FOR(Y, Y1, Y2) ckmin(MN, DP[X1][X2][Y1][Y] + DP[X1][X2][Y + 1][Y2]); DP[X1][X2][Y1][Y2] += MN; } cout << DP[1][N][1][M]; }

Compilation message (stderr)

raisins.cpp: In function 'int main()':
raisins.cpp:72:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   72 |         if (X1 == X2 && Y1 == Y2) continue; DP[X1][X2][Y1][Y2] = query(X1, X2, Y1, Y2); ll MN = INF;
      |         ^~
raisins.cpp:72:45: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   72 |         if (X1 == X2 && Y1 == Y2) continue; DP[X1][X2][Y1][Y2] = query(X1, X2, Y1, Y2); ll MN = INF;
      |                                             ^~
#Verdict Execution timeMemoryGrader output
Fetching results...