답안 #1116030

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1116030 2024-11-21T08:00:21 Z Dan4Life Coin Collecting (JOI19_ho_t4) C++17
8 / 100
132 ms 15000 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = (int)1e6+1e5;
const int LINF = (int)2e18;
int n, x[N], y[N];
array<int,2> a[N];
int dp[N];
int32_t main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n; n*=2;
    for(int i = 0; i < n; i++) cin >> x[i] >> y[i];
    for(int i = 1; i <= n; i+=2)
        a[i] = {i/2+1,1}, a[i+1] = {i/2+1,2};
    dp[0] = 0;
    for(int mask = 1; mask < (1<<n); mask++){
        int num = __builtin_popcount(mask);
        dp[mask] = LINF;
        for(int i = 0; i < n; i++){
            if(mask>>i&1){
                dp[mask] = min(dp[mask], dp[mask^(1<<i)]
                +abs(a[num][0]-x[i])+abs(a[num][1]-y[i]));
            }
        }
    }
    cout << dp[(1<<n)-1] << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6480 KB Output is correct
2 Correct 1 ms 6672 KB Output is correct
3 Correct 1 ms 6644 KB Output is correct
4 Correct 84 ms 14992 KB Output is correct
5 Correct 77 ms 14928 KB Output is correct
6 Correct 78 ms 14920 KB Output is correct
7 Correct 76 ms 14924 KB Output is correct
8 Correct 88 ms 14920 KB Output is correct
9 Correct 91 ms 14920 KB Output is correct
10 Correct 94 ms 14920 KB Output is correct
11 Correct 78 ms 14740 KB Output is correct
12 Correct 77 ms 14992 KB Output is correct
13 Correct 79 ms 14996 KB Output is correct
14 Correct 93 ms 14920 KB Output is correct
15 Correct 76 ms 14984 KB Output is correct
16 Correct 85 ms 14992 KB Output is correct
17 Correct 78 ms 15000 KB Output is correct
18 Correct 77 ms 14920 KB Output is correct
19 Correct 77 ms 14920 KB Output is correct
20 Correct 77 ms 14992 KB Output is correct
21 Correct 75 ms 14992 KB Output is correct
22 Correct 89 ms 14984 KB Output is correct
23 Correct 76 ms 14924 KB Output is correct
24 Correct 77 ms 14988 KB Output is correct
25 Correct 89 ms 14920 KB Output is correct
26 Correct 76 ms 14928 KB Output is correct
27 Correct 81 ms 14920 KB Output is correct
28 Correct 81 ms 14924 KB Output is correct
29 Correct 75 ms 14988 KB Output is correct
30 Correct 75 ms 14988 KB Output is correct
31 Correct 78 ms 14920 KB Output is correct
32 Correct 82 ms 14920 KB Output is correct
33 Correct 78 ms 14920 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6480 KB Output is correct
2 Correct 1 ms 6672 KB Output is correct
3 Correct 1 ms 6644 KB Output is correct
4 Correct 84 ms 14992 KB Output is correct
5 Correct 77 ms 14928 KB Output is correct
6 Correct 78 ms 14920 KB Output is correct
7 Correct 76 ms 14924 KB Output is correct
8 Correct 88 ms 14920 KB Output is correct
9 Correct 91 ms 14920 KB Output is correct
10 Correct 94 ms 14920 KB Output is correct
11 Correct 78 ms 14740 KB Output is correct
12 Correct 77 ms 14992 KB Output is correct
13 Correct 79 ms 14996 KB Output is correct
14 Correct 93 ms 14920 KB Output is correct
15 Correct 76 ms 14984 KB Output is correct
16 Correct 85 ms 14992 KB Output is correct
17 Correct 78 ms 15000 KB Output is correct
18 Correct 77 ms 14920 KB Output is correct
19 Correct 77 ms 14920 KB Output is correct
20 Correct 77 ms 14992 KB Output is correct
21 Correct 75 ms 14992 KB Output is correct
22 Correct 89 ms 14984 KB Output is correct
23 Correct 76 ms 14924 KB Output is correct
24 Correct 77 ms 14988 KB Output is correct
25 Correct 89 ms 14920 KB Output is correct
26 Correct 76 ms 14928 KB Output is correct
27 Correct 81 ms 14920 KB Output is correct
28 Correct 81 ms 14924 KB Output is correct
29 Correct 75 ms 14988 KB Output is correct
30 Correct 75 ms 14988 KB Output is correct
31 Correct 78 ms 14920 KB Output is correct
32 Correct 82 ms 14920 KB Output is correct
33 Correct 78 ms 14920 KB Output is correct
34 Incorrect 132 ms 8656 KB Output isn't correct
35 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6480 KB Output is correct
2 Correct 1 ms 6672 KB Output is correct
3 Correct 1 ms 6644 KB Output is correct
4 Correct 84 ms 14992 KB Output is correct
5 Correct 77 ms 14928 KB Output is correct
6 Correct 78 ms 14920 KB Output is correct
7 Correct 76 ms 14924 KB Output is correct
8 Correct 88 ms 14920 KB Output is correct
9 Correct 91 ms 14920 KB Output is correct
10 Correct 94 ms 14920 KB Output is correct
11 Correct 78 ms 14740 KB Output is correct
12 Correct 77 ms 14992 KB Output is correct
13 Correct 79 ms 14996 KB Output is correct
14 Correct 93 ms 14920 KB Output is correct
15 Correct 76 ms 14984 KB Output is correct
16 Correct 85 ms 14992 KB Output is correct
17 Correct 78 ms 15000 KB Output is correct
18 Correct 77 ms 14920 KB Output is correct
19 Correct 77 ms 14920 KB Output is correct
20 Correct 77 ms 14992 KB Output is correct
21 Correct 75 ms 14992 KB Output is correct
22 Correct 89 ms 14984 KB Output is correct
23 Correct 76 ms 14924 KB Output is correct
24 Correct 77 ms 14988 KB Output is correct
25 Correct 89 ms 14920 KB Output is correct
26 Correct 76 ms 14928 KB Output is correct
27 Correct 81 ms 14920 KB Output is correct
28 Correct 81 ms 14924 KB Output is correct
29 Correct 75 ms 14988 KB Output is correct
30 Correct 75 ms 14988 KB Output is correct
31 Correct 78 ms 14920 KB Output is correct
32 Correct 82 ms 14920 KB Output is correct
33 Correct 78 ms 14920 KB Output is correct
34 Incorrect 132 ms 8656 KB Output isn't correct
35 Halted 0 ms 0 KB -