Submission #791570

# Submission time Handle Problem Language Result Execution time Memory
791570 2023-07-24T07:32:51 Z 이종영(#10079) Netrpeljivost (COI23_netrpeljivost) C++17
59 / 100
1500 ms 53732 KB
#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
//#include <bits/extc++.h>
//using namespace __gnu_pbds;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
using ll=long long;
using tll=array<ll,3>;
const ll inf=1e18;
const int N=2222;
int n,c[N][N];
ll dp[N][N];
ll ans=inf;
void solve(int l,int r){
	if(l==r){
		dp[l][r]=0;
		return;
	}
	if(l+1==r){
		dp[l][l]=dp[r][r]=0;
		dp[l][r]=dp[r][l]=c[l][r];
		return;
	}
	int m=(l+r)>>1;
	solve(l,m);
	solve(m+1,r);
	int ml=(l+m)/2,mr=(m+1+r)/2;
	for(int i1=l;i1<=ml;i1++) for(int i2=ml+1;i2<=m;i2++)
	for(int j1=m+1;j1<=mr;j1++) for(int j2=mr+1;j2<=r;j2++){
		dp[i1][j2]=min(dp[i1][j2],dp[i1][i2]+c[i2][j1]+dp[j1][j2]);
		dp[i1][j1]=min(dp[i1][j1],dp[i1][i2]+c[i2][j2]+dp[j2][j1]);
		dp[i2][j2]=min(dp[i2][j2],dp[i2][i1]+c[i1][j1]+dp[j1][j2]);
		dp[i2][j1]=min(dp[i2][j1],dp[i2][i1]+c[i1][j2]+dp[j2][j1]);
	}
	for(int i=l;i<=m;i++) for(int j=m+1;j<=r;j++) dp[j][i]=dp[i][j];
}
int main(){
	ios::sync_with_stdio(false); cin.tie(0);
	cin>>n;
	for(int i=0;i<n;i++) for(int j=0;j<n;j++) cin>>c[i][j];
	for(int i=0;i<n;i++) for(int j=0;j<n;j++) dp[i][j]=inf;
	solve(0,n-1);
	for(int i=0;i<n/2;i++) for(int j=n/2;j<n;j++) ans=min({ans,dp[i][j],dp[j][i]});
	cout<<ans;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 6 ms 1492 KB Output is correct
22 Correct 6 ms 1536 KB Output is correct
23 Correct 6 ms 1492 KB Output is correct
24 Correct 1 ms 852 KB Output is correct
25 Correct 1 ms 852 KB Output is correct
26 Correct 6 ms 1540 KB Output is correct
27 Correct 6 ms 1492 KB Output is correct
28 Correct 6 ms 1492 KB Output is correct
29 Correct 6 ms 1492 KB Output is correct
30 Correct 6 ms 1492 KB Output is correct
31 Correct 6 ms 1536 KB Output is correct
32 Correct 6 ms 1492 KB Output is correct
33 Correct 7 ms 1540 KB Output is correct
34 Correct 6 ms 1492 KB Output is correct
35 Correct 5 ms 1492 KB Output is correct
36 Correct 6 ms 1536 KB Output is correct
37 Correct 6 ms 1492 KB Output is correct
38 Correct 6 ms 1540 KB Output is correct
39 Correct 6 ms 1492 KB Output is correct
40 Correct 10 ms 1540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 6 ms 1492 KB Output is correct
22 Correct 6 ms 1536 KB Output is correct
23 Correct 6 ms 1492 KB Output is correct
24 Correct 1 ms 852 KB Output is correct
25 Correct 1 ms 852 KB Output is correct
26 Correct 6 ms 1540 KB Output is correct
27 Correct 6 ms 1492 KB Output is correct
28 Correct 6 ms 1492 KB Output is correct
29 Correct 6 ms 1492 KB Output is correct
30 Correct 6 ms 1492 KB Output is correct
31 Correct 6 ms 1536 KB Output is correct
32 Correct 6 ms 1492 KB Output is correct
33 Correct 7 ms 1540 KB Output is correct
34 Correct 6 ms 1492 KB Output is correct
35 Correct 5 ms 1492 KB Output is correct
36 Correct 6 ms 1536 KB Output is correct
37 Correct 6 ms 1492 KB Output is correct
38 Correct 6 ms 1540 KB Output is correct
39 Correct 6 ms 1492 KB Output is correct
40 Correct 10 ms 1540 KB Output is correct
41 Correct 1121 ms 7496 KB Output is correct
42 Correct 1052 ms 7500 KB Output is correct
43 Correct 1048 ms 7488 KB Output is correct
44 Correct 1035 ms 7492 KB Output is correct
45 Correct 1087 ms 7492 KB Output is correct
46 Correct 1056 ms 7488 KB Output is correct
47 Correct 1097 ms 7504 KB Output is correct
48 Correct 1096 ms 7488 KB Output is correct
49 Correct 1050 ms 7488 KB Output is correct
50 Correct 1044 ms 7492 KB Output is correct
51 Correct 1050 ms 7492 KB Output is correct
52 Correct 1049 ms 7488 KB Output is correct
53 Correct 1033 ms 7508 KB Output is correct
54 Correct 1035 ms 7488 KB Output is correct
55 Correct 1090 ms 7492 KB Output is correct
56 Correct 1075 ms 7492 KB Output is correct
57 Correct 1061 ms 7496 KB Output is correct
58 Correct 1053 ms 7496 KB Output is correct
59 Correct 1078 ms 7380 KB Output is correct
60 Correct 1040 ms 7500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 6 ms 1492 KB Output is correct
22 Correct 6 ms 1536 KB Output is correct
23 Correct 6 ms 1492 KB Output is correct
24 Correct 1 ms 852 KB Output is correct
25 Correct 1 ms 852 KB Output is correct
26 Correct 6 ms 1540 KB Output is correct
27 Correct 6 ms 1492 KB Output is correct
28 Correct 6 ms 1492 KB Output is correct
29 Correct 6 ms 1492 KB Output is correct
30 Correct 6 ms 1492 KB Output is correct
31 Correct 6 ms 1536 KB Output is correct
32 Correct 6 ms 1492 KB Output is correct
33 Correct 7 ms 1540 KB Output is correct
34 Correct 6 ms 1492 KB Output is correct
35 Correct 5 ms 1492 KB Output is correct
36 Correct 6 ms 1536 KB Output is correct
37 Correct 6 ms 1492 KB Output is correct
38 Correct 6 ms 1540 KB Output is correct
39 Correct 6 ms 1492 KB Output is correct
40 Correct 10 ms 1540 KB Output is correct
41 Correct 1121 ms 7496 KB Output is correct
42 Correct 1052 ms 7500 KB Output is correct
43 Correct 1048 ms 7488 KB Output is correct
44 Correct 1035 ms 7492 KB Output is correct
45 Correct 1087 ms 7492 KB Output is correct
46 Correct 1056 ms 7488 KB Output is correct
47 Correct 1097 ms 7504 KB Output is correct
48 Correct 1096 ms 7488 KB Output is correct
49 Correct 1050 ms 7488 KB Output is correct
50 Correct 1044 ms 7492 KB Output is correct
51 Correct 1050 ms 7492 KB Output is correct
52 Correct 1049 ms 7488 KB Output is correct
53 Correct 1033 ms 7508 KB Output is correct
54 Correct 1035 ms 7488 KB Output is correct
55 Correct 1090 ms 7492 KB Output is correct
56 Correct 1075 ms 7492 KB Output is correct
57 Correct 1061 ms 7496 KB Output is correct
58 Correct 1053 ms 7496 KB Output is correct
59 Correct 1078 ms 7380 KB Output is correct
60 Correct 1040 ms 7500 KB Output is correct
61 Execution timed out 1576 ms 53732 KB Time limit exceeded
62 Halted 0 ms 0 KB -