답안 #1114124

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1114124 2024-11-18T08:16:47 Z SalihSahin Netrpeljivost (COI23_netrpeljivost) C++14
27 / 100
1500 ms 39496 KB
#include <bits/stdc++.h>
#define pb push_back
#define int long long
using namespace std;
 
const int inf = 1e15 + 10;
const int N = 2048 + 10;
 
vector<vector<int> > c(N, vector<int>(N));
vector<vector<int> > dp[N];
 
void f(int node, int l, int r){
   if(l == r){
      dp[node].resize(1);
      dp[node][0].resize(1);
      dp[node][0][0] = 0;
      return;
   }
 
   int m = (l + r)/2;
   f(node * 2, l, m);
   f(node * 2 + 1, m+1, r);
 
   int sz = (r - l + 1);
   dp[node].resize(sz);
   for(int i = 0; i < sz; i++){
      dp[node][i].resize(sz);
   }
 
   for(int i = 0; i < sz; i++){
      for(int j = 0; j < sz; j++){
         dp[node][i][j] = inf;
      }
   }

   for(int l1 = 0; l1 < sz/2; l1++){
      for(int r2 = 0; r2 < sz/2; r2++){
         for(int l2 = 0; l2 < sz/2; l2++){
            for(int r1 = 0; r1 < sz/2; r1++){
               dp[node][l1][r2 + sz/2] = min(dp[node][l1][r2 + sz/2], dp[node*2][l1][r1] + c[l2 + sz/2 + l][r1 + l] + dp[node*2+1][l2][r2]);
            }
         }
      }
   }

   for(int l2 = 0; l2 < sz/2; l2++){
      for(int r1 = 0; r1 < sz/2; r1++){
         for(int l1 = 0; l1 < sz/2; l1++){
            for(int r2 = 0; r2 < sz/2; r2++){
               dp[node][l2 + sz/2][r1] = min(dp[node][l2 + sz/2][r1], dp[node*2+1][l2][r2] + c[r2 + sz/2 + l][l1 + l] + dp[node*2][l1][r1]);
            }
         }
      }
   }
}
 
int32_t main(){
   ios_base::sync_with_stdio(false);
   cin.tie(0); cout.tie(0);
   int n;
   cin>>n;
   for(int i = 0; i < n; i++){
      for(int j = 0; j < n; j++){
         cin>>c[i][j];
      }
   }
   f(1, 0, n-1);
 
   int ans = inf;
   for(int l = 0; l < n; l++){
      for(int r = 0; r < n; r++){
         //cout<<l<<" "<<r<<" -> "<<dp[1][l][r]<<endl;
         ans = min(ans, dp[1][l][r]);
      }
   }
   cout<<ans<<endl;
   return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 33616 KB Output is correct
2 Correct 24 ms 33616 KB Output is correct
3 Correct 26 ms 33616 KB Output is correct
4 Correct 24 ms 33616 KB Output is correct
5 Correct 25 ms 33632 KB Output is correct
6 Correct 25 ms 33608 KB Output is correct
7 Correct 24 ms 33616 KB Output is correct
8 Correct 25 ms 33616 KB Output is correct
9 Correct 26 ms 33608 KB Output is correct
10 Correct 25 ms 33616 KB Output is correct
11 Correct 24 ms 33608 KB Output is correct
12 Correct 25 ms 33628 KB Output is correct
13 Correct 24 ms 33784 KB Output is correct
14 Correct 25 ms 33656 KB Output is correct
15 Correct 23 ms 33616 KB Output is correct
16 Correct 24 ms 33784 KB Output is correct
17 Correct 30 ms 33608 KB Output is correct
18 Correct 26 ms 33560 KB Output is correct
19 Correct 25 ms 33616 KB Output is correct
20 Correct 27 ms 33616 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 33616 KB Output is correct
2 Correct 24 ms 33616 KB Output is correct
3 Correct 26 ms 33616 KB Output is correct
4 Correct 24 ms 33616 KB Output is correct
5 Correct 25 ms 33632 KB Output is correct
6 Correct 25 ms 33608 KB Output is correct
7 Correct 24 ms 33616 KB Output is correct
8 Correct 25 ms 33616 KB Output is correct
9 Correct 26 ms 33608 KB Output is correct
10 Correct 25 ms 33616 KB Output is correct
11 Correct 24 ms 33608 KB Output is correct
12 Correct 25 ms 33628 KB Output is correct
13 Correct 24 ms 33784 KB Output is correct
14 Correct 25 ms 33656 KB Output is correct
15 Correct 23 ms 33616 KB Output is correct
16 Correct 24 ms 33784 KB Output is correct
17 Correct 30 ms 33608 KB Output is correct
18 Correct 26 ms 33560 KB Output is correct
19 Correct 25 ms 33616 KB Output is correct
20 Correct 27 ms 33616 KB Output is correct
21 Correct 63 ms 34120 KB Output is correct
22 Correct 63 ms 34120 KB Output is correct
23 Correct 65 ms 34120 KB Output is correct
24 Correct 27 ms 33684 KB Output is correct
25 Correct 29 ms 33872 KB Output is correct
26 Correct 72 ms 34128 KB Output is correct
27 Correct 69 ms 34120 KB Output is correct
28 Correct 62 ms 33872 KB Output is correct
29 Correct 66 ms 34096 KB Output is correct
30 Correct 69 ms 33872 KB Output is correct
31 Correct 63 ms 34128 KB Output is correct
32 Correct 65 ms 34012 KB Output is correct
33 Correct 63 ms 33980 KB Output is correct
34 Correct 62 ms 33872 KB Output is correct
35 Correct 65 ms 34128 KB Output is correct
36 Correct 64 ms 34124 KB Output is correct
37 Correct 82 ms 33964 KB Output is correct
38 Correct 64 ms 34128 KB Output is correct
39 Correct 65 ms 34120 KB Output is correct
40 Correct 76 ms 34120 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 33616 KB Output is correct
2 Correct 24 ms 33616 KB Output is correct
3 Correct 26 ms 33616 KB Output is correct
4 Correct 24 ms 33616 KB Output is correct
5 Correct 25 ms 33632 KB Output is correct
6 Correct 25 ms 33608 KB Output is correct
7 Correct 24 ms 33616 KB Output is correct
8 Correct 25 ms 33616 KB Output is correct
9 Correct 26 ms 33608 KB Output is correct
10 Correct 25 ms 33616 KB Output is correct
11 Correct 24 ms 33608 KB Output is correct
12 Correct 25 ms 33628 KB Output is correct
13 Correct 24 ms 33784 KB Output is correct
14 Correct 25 ms 33656 KB Output is correct
15 Correct 23 ms 33616 KB Output is correct
16 Correct 24 ms 33784 KB Output is correct
17 Correct 30 ms 33608 KB Output is correct
18 Correct 26 ms 33560 KB Output is correct
19 Correct 25 ms 33616 KB Output is correct
20 Correct 27 ms 33616 KB Output is correct
21 Correct 63 ms 34120 KB Output is correct
22 Correct 63 ms 34120 KB Output is correct
23 Correct 65 ms 34120 KB Output is correct
24 Correct 27 ms 33684 KB Output is correct
25 Correct 29 ms 33872 KB Output is correct
26 Correct 72 ms 34128 KB Output is correct
27 Correct 69 ms 34120 KB Output is correct
28 Correct 62 ms 33872 KB Output is correct
29 Correct 66 ms 34096 KB Output is correct
30 Correct 69 ms 33872 KB Output is correct
31 Correct 63 ms 34128 KB Output is correct
32 Correct 65 ms 34012 KB Output is correct
33 Correct 63 ms 33980 KB Output is correct
34 Correct 62 ms 33872 KB Output is correct
35 Correct 65 ms 34128 KB Output is correct
36 Correct 64 ms 34124 KB Output is correct
37 Correct 82 ms 33964 KB Output is correct
38 Correct 64 ms 34128 KB Output is correct
39 Correct 65 ms 34120 KB Output is correct
40 Correct 76 ms 34120 KB Output is correct
41 Execution timed out 1539 ms 39496 KB Time limit exceeded
42 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 33616 KB Output is correct
2 Correct 24 ms 33616 KB Output is correct
3 Correct 26 ms 33616 KB Output is correct
4 Correct 24 ms 33616 KB Output is correct
5 Correct 25 ms 33632 KB Output is correct
6 Correct 25 ms 33608 KB Output is correct
7 Correct 24 ms 33616 KB Output is correct
8 Correct 25 ms 33616 KB Output is correct
9 Correct 26 ms 33608 KB Output is correct
10 Correct 25 ms 33616 KB Output is correct
11 Correct 24 ms 33608 KB Output is correct
12 Correct 25 ms 33628 KB Output is correct
13 Correct 24 ms 33784 KB Output is correct
14 Correct 25 ms 33656 KB Output is correct
15 Correct 23 ms 33616 KB Output is correct
16 Correct 24 ms 33784 KB Output is correct
17 Correct 30 ms 33608 KB Output is correct
18 Correct 26 ms 33560 KB Output is correct
19 Correct 25 ms 33616 KB Output is correct
20 Correct 27 ms 33616 KB Output is correct
21 Correct 63 ms 34120 KB Output is correct
22 Correct 63 ms 34120 KB Output is correct
23 Correct 65 ms 34120 KB Output is correct
24 Correct 27 ms 33684 KB Output is correct
25 Correct 29 ms 33872 KB Output is correct
26 Correct 72 ms 34128 KB Output is correct
27 Correct 69 ms 34120 KB Output is correct
28 Correct 62 ms 33872 KB Output is correct
29 Correct 66 ms 34096 KB Output is correct
30 Correct 69 ms 33872 KB Output is correct
31 Correct 63 ms 34128 KB Output is correct
32 Correct 65 ms 34012 KB Output is correct
33 Correct 63 ms 33980 KB Output is correct
34 Correct 62 ms 33872 KB Output is correct
35 Correct 65 ms 34128 KB Output is correct
36 Correct 64 ms 34124 KB Output is correct
37 Correct 82 ms 33964 KB Output is correct
38 Correct 64 ms 34128 KB Output is correct
39 Correct 65 ms 34120 KB Output is correct
40 Correct 76 ms 34120 KB Output is correct
41 Execution timed out 1539 ms 39496 KB Time limit exceeded
42 Halted 0 ms 0 KB -