답안 #1061149

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1061149 2024-08-16T06:40:23 Z NeroZein Netrpeljivost (COI23_netrpeljivost) C++17
59 / 100
1500 ms 155868 KB
#include "bits/stdc++.h"
using namespace std;

#ifdef Nero
#include "Deb.h"
#else
#define debug(...)
#endif

const int N = 2050;
const long long INF = 1e15;

int a[N][N];
long long dp[N][N];
long long ndp[N][N];
long long dp2[N][N];

void solve(int l, int r) {
  if (l + 1 == r) {
    dp[l][r] = dp[r][l] = a[l][r];
    return;
  }
  int mid = (l + r) / 2;
  solve(l, mid);
  solve(mid + 1, r);
  for (int i = l; i <= r; ++i) {
    for (int j = l; j <= r; ++j) {
      ndp[i][j] = ndp[j][i] = INF;
      dp2[i][j] = dp2[j][i] = INF;
    }
  }
  for (int i = l; i <= mid; ++i) {
    for (int j = mid + 1; j <= r; ++j) {
      for (int k = l; k <= mid; ++k) {
        if (k == i) continue;
        dp2[i][j] = min(dp2[i][j], dp[i][k] + a[j][k]);
      }
      for (int k = mid + 1; k <= r; ++k) {
        if (k == j) continue;
        ndp[i][k] = min(ndp[i][k], dp2[i][j] + dp[j][k]);
      }
    }
  }
  for (int i = l; i <= mid; ++i) {
    for (int j = mid + 1; j <= r; ++j) {
      dp[i][j] = dp[j][i] = ndp[i][j];
    }
  }
  for (int i = l; i <= mid; ++i) {
    for (int j = l; j <= mid; ++j) {
      dp[i][j] = INF;
    }
  }
  for (int i = mid + 1; i <= r; ++i) {
    for (int j = mid + 1; j <= r; ++j) {
      dp[i][j] = INF;
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      cin >> a[i][j];
    }
  }
  solve(1, n);
  long long ans = INF;
  for (int i = 1; i <= n / 2; ++i) {
    for (int j = n / 2 + 1; j <= n; ++j) {
      ans = min(ans, dp[i][j]);
      ans = min(ans, dp[j][i]);
    }
  }
  cout << ans << '\n';
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 12636 KB Output is correct
2 Correct 1 ms 12636 KB Output is correct
3 Correct 1 ms 12748 KB Output is correct
4 Correct 2 ms 12760 KB Output is correct
5 Correct 1 ms 12636 KB Output is correct
6 Correct 1 ms 12636 KB Output is correct
7 Correct 1 ms 12636 KB Output is correct
8 Correct 1 ms 12636 KB Output is correct
9 Correct 1 ms 12632 KB Output is correct
10 Correct 1 ms 12636 KB Output is correct
11 Correct 1 ms 12636 KB Output is correct
12 Correct 1 ms 12752 KB Output is correct
13 Correct 2 ms 12632 KB Output is correct
14 Correct 1 ms 12768 KB Output is correct
15 Correct 1 ms 12632 KB Output is correct
16 Correct 1 ms 12636 KB Output is correct
17 Correct 1 ms 12636 KB Output is correct
18 Correct 1 ms 12636 KB Output is correct
19 Correct 1 ms 12636 KB Output is correct
20 Correct 1 ms 12632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 12636 KB Output is correct
2 Correct 1 ms 12636 KB Output is correct
3 Correct 1 ms 12748 KB Output is correct
4 Correct 2 ms 12760 KB Output is correct
5 Correct 1 ms 12636 KB Output is correct
6 Correct 1 ms 12636 KB Output is correct
7 Correct 1 ms 12636 KB Output is correct
8 Correct 1 ms 12636 KB Output is correct
9 Correct 1 ms 12632 KB Output is correct
10 Correct 1 ms 12636 KB Output is correct
11 Correct 1 ms 12636 KB Output is correct
12 Correct 1 ms 12752 KB Output is correct
13 Correct 2 ms 12632 KB Output is correct
14 Correct 1 ms 12768 KB Output is correct
15 Correct 1 ms 12632 KB Output is correct
16 Correct 1 ms 12636 KB Output is correct
17 Correct 1 ms 12636 KB Output is correct
18 Correct 1 ms 12636 KB Output is correct
19 Correct 1 ms 12636 KB Output is correct
20 Correct 1 ms 12632 KB Output is correct
21 Correct 3 ms 12892 KB Output is correct
22 Correct 3 ms 12892 KB Output is correct
23 Correct 4 ms 12912 KB Output is correct
24 Correct 2 ms 12636 KB Output is correct
25 Correct 2 ms 12764 KB Output is correct
26 Correct 3 ms 12868 KB Output is correct
27 Correct 3 ms 12892 KB Output is correct
28 Correct 3 ms 12892 KB Output is correct
29 Correct 4 ms 12980 KB Output is correct
30 Correct 3 ms 12892 KB Output is correct
31 Correct 3 ms 12892 KB Output is correct
32 Correct 3 ms 12892 KB Output is correct
33 Correct 3 ms 12892 KB Output is correct
34 Correct 3 ms 12980 KB Output is correct
35 Correct 3 ms 12892 KB Output is correct
36 Correct 3 ms 12760 KB Output is correct
37 Correct 5 ms 12872 KB Output is correct
38 Correct 3 ms 12892 KB Output is correct
39 Correct 3 ms 12892 KB Output is correct
40 Correct 3 ms 12892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 12636 KB Output is correct
2 Correct 1 ms 12636 KB Output is correct
3 Correct 1 ms 12748 KB Output is correct
4 Correct 2 ms 12760 KB Output is correct
5 Correct 1 ms 12636 KB Output is correct
6 Correct 1 ms 12636 KB Output is correct
7 Correct 1 ms 12636 KB Output is correct
8 Correct 1 ms 12636 KB Output is correct
9 Correct 1 ms 12632 KB Output is correct
10 Correct 1 ms 12636 KB Output is correct
11 Correct 1 ms 12636 KB Output is correct
12 Correct 1 ms 12752 KB Output is correct
13 Correct 2 ms 12632 KB Output is correct
14 Correct 1 ms 12768 KB Output is correct
15 Correct 1 ms 12632 KB Output is correct
16 Correct 1 ms 12636 KB Output is correct
17 Correct 1 ms 12636 KB Output is correct
18 Correct 1 ms 12636 KB Output is correct
19 Correct 1 ms 12636 KB Output is correct
20 Correct 1 ms 12632 KB Output is correct
21 Correct 3 ms 12892 KB Output is correct
22 Correct 3 ms 12892 KB Output is correct
23 Correct 4 ms 12912 KB Output is correct
24 Correct 2 ms 12636 KB Output is correct
25 Correct 2 ms 12764 KB Output is correct
26 Correct 3 ms 12868 KB Output is correct
27 Correct 3 ms 12892 KB Output is correct
28 Correct 3 ms 12892 KB Output is correct
29 Correct 4 ms 12980 KB Output is correct
30 Correct 3 ms 12892 KB Output is correct
31 Correct 3 ms 12892 KB Output is correct
32 Correct 3 ms 12892 KB Output is correct
33 Correct 3 ms 12892 KB Output is correct
34 Correct 3 ms 12980 KB Output is correct
35 Correct 3 ms 12892 KB Output is correct
36 Correct 3 ms 12760 KB Output is correct
37 Correct 5 ms 12872 KB Output is correct
38 Correct 3 ms 12892 KB Output is correct
39 Correct 3 ms 12892 KB Output is correct
40 Correct 3 ms 12892 KB Output is correct
41 Correct 60 ms 37716 KB Output is correct
42 Correct 60 ms 37716 KB Output is correct
43 Correct 61 ms 37716 KB Output is correct
44 Correct 62 ms 37724 KB Output is correct
45 Correct 75 ms 37716 KB Output is correct
46 Correct 62 ms 37724 KB Output is correct
47 Correct 62 ms 37936 KB Output is correct
48 Correct 61 ms 37892 KB Output is correct
49 Correct 60 ms 37716 KB Output is correct
50 Correct 60 ms 37724 KB Output is correct
51 Correct 60 ms 37968 KB Output is correct
52 Correct 61 ms 37972 KB Output is correct
53 Correct 62 ms 37972 KB Output is correct
54 Correct 68 ms 37976 KB Output is correct
55 Correct 64 ms 37972 KB Output is correct
56 Correct 60 ms 37980 KB Output is correct
57 Correct 61 ms 37816 KB Output is correct
58 Correct 60 ms 37976 KB Output is correct
59 Correct 62 ms 37952 KB Output is correct
60 Correct 60 ms 37972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 12636 KB Output is correct
2 Correct 1 ms 12636 KB Output is correct
3 Correct 1 ms 12748 KB Output is correct
4 Correct 2 ms 12760 KB Output is correct
5 Correct 1 ms 12636 KB Output is correct
6 Correct 1 ms 12636 KB Output is correct
7 Correct 1 ms 12636 KB Output is correct
8 Correct 1 ms 12636 KB Output is correct
9 Correct 1 ms 12632 KB Output is correct
10 Correct 1 ms 12636 KB Output is correct
11 Correct 1 ms 12636 KB Output is correct
12 Correct 1 ms 12752 KB Output is correct
13 Correct 2 ms 12632 KB Output is correct
14 Correct 1 ms 12768 KB Output is correct
15 Correct 1 ms 12632 KB Output is correct
16 Correct 1 ms 12636 KB Output is correct
17 Correct 1 ms 12636 KB Output is correct
18 Correct 1 ms 12636 KB Output is correct
19 Correct 1 ms 12636 KB Output is correct
20 Correct 1 ms 12632 KB Output is correct
21 Correct 3 ms 12892 KB Output is correct
22 Correct 3 ms 12892 KB Output is correct
23 Correct 4 ms 12912 KB Output is correct
24 Correct 2 ms 12636 KB Output is correct
25 Correct 2 ms 12764 KB Output is correct
26 Correct 3 ms 12868 KB Output is correct
27 Correct 3 ms 12892 KB Output is correct
28 Correct 3 ms 12892 KB Output is correct
29 Correct 4 ms 12980 KB Output is correct
30 Correct 3 ms 12892 KB Output is correct
31 Correct 3 ms 12892 KB Output is correct
32 Correct 3 ms 12892 KB Output is correct
33 Correct 3 ms 12892 KB Output is correct
34 Correct 3 ms 12980 KB Output is correct
35 Correct 3 ms 12892 KB Output is correct
36 Correct 3 ms 12760 KB Output is correct
37 Correct 5 ms 12872 KB Output is correct
38 Correct 3 ms 12892 KB Output is correct
39 Correct 3 ms 12892 KB Output is correct
40 Correct 3 ms 12892 KB Output is correct
41 Correct 60 ms 37716 KB Output is correct
42 Correct 60 ms 37716 KB Output is correct
43 Correct 61 ms 37716 KB Output is correct
44 Correct 62 ms 37724 KB Output is correct
45 Correct 75 ms 37716 KB Output is correct
46 Correct 62 ms 37724 KB Output is correct
47 Correct 62 ms 37936 KB Output is correct
48 Correct 61 ms 37892 KB Output is correct
49 Correct 60 ms 37716 KB Output is correct
50 Correct 60 ms 37724 KB Output is correct
51 Correct 60 ms 37968 KB Output is correct
52 Correct 61 ms 37972 KB Output is correct
53 Correct 62 ms 37972 KB Output is correct
54 Correct 68 ms 37976 KB Output is correct
55 Correct 64 ms 37972 KB Output is correct
56 Correct 60 ms 37980 KB Output is correct
57 Correct 61 ms 37816 KB Output is correct
58 Correct 60 ms 37976 KB Output is correct
59 Correct 62 ms 37952 KB Output is correct
60 Correct 60 ms 37972 KB Output is correct
61 Execution timed out 1523 ms 155868 KB Time limit exceeded
62 Halted 0 ms 0 KB -