Submission #791625

# Submission time Handle Problem Language Result Execution time Memory
791625 2023-07-24T08:11:51 Z 반딧불(#10046) Netrpeljivost (COI23_netrpeljivost) C++17
59 / 100
1500 ms 99940 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const ll INF = 1e18;

int n;
ll arr[2050][2050];
ll DP[2050][2050];
ll mid[2050][2050];
ll ans;

void dfs(int l, int r){
    if(r-l==1){
        DP[l][r] = DP[r][l] = arr[l][r];
        return;
    }
    int m = (l+r)>>1;
    dfs(l, m);
    dfs(m+1, r);

    int m1 = (l+m)/2;
    for(int i=l; i<=m; i++) for(int j=l; j<=m; j++) for(int k=m+1; k<=r; k++){
        if((i<=m1) == (j<=m1)) continue;
        mid[i][k] = min(mid[i][k], DP[i][j] + arr[j][k]);
    }
    int m2 = (m+1+r)/2;
    for(int i=l; i<=m; i++) for(int j=m+1; j<=r; j++) for(int k=m+1; k<=r; k++){
        if((j<=m2) == (k<=m2)) continue;
        DP[k][i] = DP[i][k] = min(DP[i][k], mid[i][j] + DP[j][k]);
    }
}

int main(){
    scanf("%d", &n);
    for(int i=1; i<=n; i++){
        for(int j=1; j<=n; j++){
            scanf("%lld", &arr[i][j]);
            DP[i][j] = mid[i][j] = INF;
        }
    }
    dfs(1, n);
    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]);
    printf("%lld", ans);
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:36:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
Main.cpp:39:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |             scanf("%lld", &arr[i][j]);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 0 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 0 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 0 ms 468 KB Output is correct
7 Correct 0 ms 468 KB Output is correct
8 Correct 0 ms 468 KB Output is correct
9 Correct 0 ms 468 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 0 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 0 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 0 ms 468 KB Output is correct
18 Correct 0 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 0 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 0 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 0 ms 468 KB Output is correct
7 Correct 0 ms 468 KB Output is correct
8 Correct 0 ms 468 KB Output is correct
9 Correct 0 ms 468 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 0 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 0 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 0 ms 468 KB Output is correct
18 Correct 0 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 5 ms 2228 KB Output is correct
22 Correct 4 ms 2196 KB Output is correct
23 Correct 4 ms 2260 KB Output is correct
24 Correct 2 ms 980 KB Output is correct
25 Correct 1 ms 980 KB Output is correct
26 Correct 3 ms 2260 KB Output is correct
27 Correct 3 ms 2172 KB Output is correct
28 Correct 3 ms 2260 KB Output is correct
29 Correct 3 ms 2260 KB Output is correct
30 Correct 5 ms 2132 KB Output is correct
31 Correct 3 ms 2260 KB Output is correct
32 Correct 3 ms 2172 KB Output is correct
33 Correct 3 ms 2260 KB Output is correct
34 Correct 3 ms 2236 KB Output is correct
35 Correct 3 ms 2260 KB Output is correct
36 Correct 3 ms 2260 KB Output is correct
37 Correct 3 ms 2232 KB Output is correct
38 Correct 3 ms 2132 KB Output is correct
39 Correct 3 ms 2132 KB Output is correct
40 Correct 3 ms 2200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 0 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 0 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 0 ms 468 KB Output is correct
7 Correct 0 ms 468 KB Output is correct
8 Correct 0 ms 468 KB Output is correct
9 Correct 0 ms 468 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 0 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 0 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 0 ms 468 KB Output is correct
18 Correct 0 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 5 ms 2228 KB Output is correct
22 Correct 4 ms 2196 KB Output is correct
23 Correct 4 ms 2260 KB Output is correct
24 Correct 2 ms 980 KB Output is correct
25 Correct 1 ms 980 KB Output is correct
26 Correct 3 ms 2260 KB Output is correct
27 Correct 3 ms 2172 KB Output is correct
28 Correct 3 ms 2260 KB Output is correct
29 Correct 3 ms 2260 KB Output is correct
30 Correct 5 ms 2132 KB Output is correct
31 Correct 3 ms 2260 KB Output is correct
32 Correct 3 ms 2172 KB Output is correct
33 Correct 3 ms 2260 KB Output is correct
34 Correct 3 ms 2236 KB Output is correct
35 Correct 3 ms 2260 KB Output is correct
36 Correct 3 ms 2260 KB Output is correct
37 Correct 3 ms 2232 KB Output is correct
38 Correct 3 ms 2132 KB Output is correct
39 Correct 3 ms 2132 KB Output is correct
40 Correct 3 ms 2200 KB Output is correct
41 Correct 64 ms 12620 KB Output is correct
42 Correct 65 ms 12636 KB Output is correct
43 Correct 68 ms 12632 KB Output is correct
44 Correct 68 ms 12632 KB Output is correct
45 Correct 63 ms 12632 KB Output is correct
46 Correct 65 ms 12540 KB Output is correct
47 Correct 64 ms 12636 KB Output is correct
48 Correct 69 ms 12632 KB Output is correct
49 Correct 68 ms 12576 KB Output is correct
50 Correct 64 ms 12620 KB Output is correct
51 Correct 65 ms 12624 KB Output is correct
52 Correct 66 ms 12632 KB Output is correct
53 Correct 63 ms 12624 KB Output is correct
54 Correct 74 ms 12632 KB Output is correct
55 Correct 67 ms 12524 KB Output is correct
56 Correct 80 ms 13960 KB Output is correct
57 Correct 63 ms 13940 KB Output is correct
58 Correct 67 ms 13984 KB Output is correct
59 Correct 78 ms 14160 KB Output is correct
60 Correct 67 ms 14072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 0 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 0 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 0 ms 468 KB Output is correct
7 Correct 0 ms 468 KB Output is correct
8 Correct 0 ms 468 KB Output is correct
9 Correct 0 ms 468 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 0 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 0 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 0 ms 468 KB Output is correct
18 Correct 0 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 5 ms 2228 KB Output is correct
22 Correct 4 ms 2196 KB Output is correct
23 Correct 4 ms 2260 KB Output is correct
24 Correct 2 ms 980 KB Output is correct
25 Correct 1 ms 980 KB Output is correct
26 Correct 3 ms 2260 KB Output is correct
27 Correct 3 ms 2172 KB Output is correct
28 Correct 3 ms 2260 KB Output is correct
29 Correct 3 ms 2260 KB Output is correct
30 Correct 5 ms 2132 KB Output is correct
31 Correct 3 ms 2260 KB Output is correct
32 Correct 3 ms 2172 KB Output is correct
33 Correct 3 ms 2260 KB Output is correct
34 Correct 3 ms 2236 KB Output is correct
35 Correct 3 ms 2260 KB Output is correct
36 Correct 3 ms 2260 KB Output is correct
37 Correct 3 ms 2232 KB Output is correct
38 Correct 3 ms 2132 KB Output is correct
39 Correct 3 ms 2132 KB Output is correct
40 Correct 3 ms 2200 KB Output is correct
41 Correct 64 ms 12620 KB Output is correct
42 Correct 65 ms 12636 KB Output is correct
43 Correct 68 ms 12632 KB Output is correct
44 Correct 68 ms 12632 KB Output is correct
45 Correct 63 ms 12632 KB Output is correct
46 Correct 65 ms 12540 KB Output is correct
47 Correct 64 ms 12636 KB Output is correct
48 Correct 69 ms 12632 KB Output is correct
49 Correct 68 ms 12576 KB Output is correct
50 Correct 64 ms 12620 KB Output is correct
51 Correct 65 ms 12624 KB Output is correct
52 Correct 66 ms 12632 KB Output is correct
53 Correct 63 ms 12624 KB Output is correct
54 Correct 74 ms 12632 KB Output is correct
55 Correct 67 ms 12524 KB Output is correct
56 Correct 80 ms 13960 KB Output is correct
57 Correct 63 ms 13940 KB Output is correct
58 Correct 67 ms 13984 KB Output is correct
59 Correct 78 ms 14160 KB Output is correct
60 Correct 67 ms 14072 KB Output is correct
61 Execution timed out 1585 ms 99940 KB Time limit exceeded
62 Halted 0 ms 0 KB -